diff --git a/404.html b/404.html new file mode 100644 index 00000000..9634e573 --- /dev/null +++ b/404.html @@ -0,0 +1 @@ +404 Not Found

404 Not Found

\ No newline at end of file diff --git a/CNAME b/CNAME new file mode 100644 index 00000000..3fb047cf --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +geng.kuviman.com \ No newline at end of file diff --git a/example-placeholder.html b/example-placeholder.html new file mode 100644 index 00000000..7ec4fa2b --- /dev/null +++ b/example-placeholder.html @@ -0,0 +1,55 @@ + + + + + + + + + + + +
+
+

You can see the examples here...

+

Just select one from above

+
+
+ + + \ No newline at end of file diff --git a/examples.css b/examples.css new file mode 100644 index 00000000..7bcf2cbc --- /dev/null +++ b/examples.css @@ -0,0 +1 @@ +html,body{height:100%;overflow:hidden}button{width:100%}#example-select{width:100%;height:3em;text-align:center;border-radius:0}#example-iframe-container{position:absolute;top:3em;left:0;bottom:0;right:0}#example-iframe{width:100%;height:100%;border:none} diff --git a/examples/03_moving/03_moving.js b/examples/03_moving/03_moving.js new file mode 100644 index 00000000..ba1cadc9 --- /dev/null +++ b/examples/03_moving/03_moving.js @@ -0,0 +1,1307 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-2e04217e96c54cd9/inline3.js'; +import * as __wbg_star1 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_26(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h12a08bd67ae19dbd(arg0, arg1, addHeapObject(arg2)); +} + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_35(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h8c4374991280f486(arg0, arg1); +} + +function __wbg_adapter_40(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_357(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_performance_3298a9628a5c8aa4 = function(arg0) { + const ret = getObject(arg0).performance; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_activeTexture_5f084e1b3f14853e = function(arg0, arg1) { + getObject(arg0).activeTexture(arg1 >>> 0); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_width_aee8b8809b033b05 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_now_4e659b3d15f470d9 = function(arg0) { + const ret = getObject(arg0).now(); + return ret; + }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_357(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper322 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 71, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper324 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 71, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper326 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 71, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper328 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 71, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper330 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 71, __wbg_adapter_35); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper332 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 71, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper3074 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1324, __wbg_adapter_40); + return addHeapObject(ret); + }; + imports['./snippets/geng-2e04217e96c54cd9/inline3.js'] = __wbg_star0; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star1; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/03_moving/03_moving.wasm b/examples/03_moving/03_moving.wasm new file mode 100644 index 00000000..c5589211 Binary files /dev/null and b/examples/03_moving/03_moving.wasm differ diff --git a/examples/03_moving/index.html b/examples/03_moving/index.html new file mode 100644 index 00000000..d9d90916 --- /dev/null +++ b/examples/03_moving/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/03_moving/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/03_moving/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/03_moving/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/03_moving/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/03_moving/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/03_moving/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/03_moving/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/03_moving/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/03_moving/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/03_moving/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/03_moving/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/03_moving/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/03_moving/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/03_moving/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/03_moving/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/03_moving/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/03_moving/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/03_moving/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/03_moving/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/03_moving/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/03_moving/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/03_moving/sound-fix.js b/examples/03_moving/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/03_moving/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/04_camera_controls/04_camera_controls.js b/examples/04_camera_controls/04_camera_controls.js new file mode 100644 index 00000000..2322a5e2 --- /dev/null +++ b/examples/04_camera_controls/04_camera_controls.js @@ -0,0 +1,1307 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-2e04217e96c54cd9/inline3.js'; +import * as __wbg_star1 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_26(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5923bd3338befd5a(arg0, arg1); +} + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_29(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1311d4d030754ff5(arg0, arg1, addHeapObject(arg2)); +} + +function __wbg_adapter_40(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_357(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_performance_3298a9628a5c8aa4 = function(arg0) { + const ret = getObject(arg0).performance; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_activeTexture_5f084e1b3f14853e = function(arg0, arg1) { + getObject(arg0).activeTexture(arg1 >>> 0); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_width_aee8b8809b033b05 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_now_4e659b3d15f470d9 = function(arg0) { + const ret = getObject(arg0).now(); + return ret; + }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_357(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper393 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 89, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper395 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 89, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper397 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 89, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper399 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 89, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper401 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 89, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper403 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 89, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper3076 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1320, __wbg_adapter_40); + return addHeapObject(ret); + }; + imports['./snippets/geng-2e04217e96c54cd9/inline3.js'] = __wbg_star0; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star1; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/04_camera_controls/04_camera_controls.wasm b/examples/04_camera_controls/04_camera_controls.wasm new file mode 100644 index 00000000..c77a1aa9 Binary files /dev/null and b/examples/04_camera_controls/04_camera_controls.wasm differ diff --git a/examples/04_camera_controls/index.html b/examples/04_camera_controls/index.html new file mode 100644 index 00000000..165b652b --- /dev/null +++ b/examples/04_camera_controls/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/04_camera_controls/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/04_camera_controls/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/04_camera_controls/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/04_camera_controls/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/04_camera_controls/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/04_camera_controls/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/04_camera_controls/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/04_camera_controls/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/04_camera_controls/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/04_camera_controls/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/04_camera_controls/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/04_camera_controls/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/04_camera_controls/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/04_camera_controls/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/04_camera_controls/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/04_camera_controls/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/04_camera_controls/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/04_camera_controls/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/04_camera_controls/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/04_camera_controls/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/04_camera_controls/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/04_camera_controls/sound-fix.js b/examples/04_camera_controls/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/04_camera_controls/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/crabrave/assets/back_leg.png b/examples/crabrave/assets/back_leg.png new file mode 100644 index 00000000..47106a73 Binary files /dev/null and b/examples/crabrave/assets/back_leg.png differ diff --git a/examples/crabrave/assets/body.png b/examples/crabrave/assets/body.png new file mode 100644 index 00000000..ddf1b2bd Binary files /dev/null and b/examples/crabrave/assets/body.png differ diff --git a/examples/crabrave/assets/front_leg.png b/examples/crabrave/assets/front_leg.png new file mode 100644 index 00000000..a1de2e66 Binary files /dev/null and b/examples/crabrave/assets/front_leg.png differ diff --git a/examples/crabrave/assets/hand.png b/examples/crabrave/assets/hand.png new file mode 100644 index 00000000..1bef0f4f Binary files /dev/null and b/examples/crabrave/assets/hand.png differ diff --git a/examples/crabrave/crabrave.js b/examples/crabrave/crabrave.js new file mode 100644 index 00000000..d8c3e0a6 --- /dev/null +++ b/examples/crabrave/crabrave.js @@ -0,0 +1,1340 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { setup_image } from './snippets/geng-asset-dc4ee02ddfcc1509/inline0.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-2e04217e96c54cd9/inline3.js'; +import * as __wbg_star1 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_26(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h8430c46338f2885e(arg0, arg1); +} + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_29(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h096f0e6aea8deab2(arg0, arg1, addHeapObject(arg2)); +} + +function __wbg_adapter_40(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5de5bed9ca3e124a(arg0, arg1, arg2); +} + +function __wbg_adapter_43(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_374(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_setupimage_eedb9c1b6f90a78f = function(arg0, arg1) { + setup_image(getObject(arg0), takeObject(arg1)); + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_performance_3298a9628a5c8aa4 = function(arg0) { + const ret = getObject(arg0).performance; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_texImage2D_067ff4b1e817ef37 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4 >>> 0, arg5 >>> 0, getObject(arg6)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_activeTexture_5f084e1b3f14853e = function(arg0, arg1) { + getObject(arg0).activeTexture(arg1 >>> 0); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_generateMipmap_cd6c5ba2828aac7e = function(arg0, arg1) { + getObject(arg0).generateMipmap(arg1 >>> 0); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_width_aee8b8809b033b05 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_now_4e659b3d15f470d9 = function(arg0) { + const ret = getObject(arg0).now(); + return ret; + }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_setsrc_681ceacdf6845f60 = function(arg0, arg1, arg2) { + getObject(arg0).src = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_width_59e0563d9c871704 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_1a892edafac94d49 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_new_e6ce9457ca710f38 = function() { return handleError(function () { + const ret = new Image(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_374(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper440 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 123, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper442 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 123, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper444 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 123, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper446 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 123, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper448 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 123, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper450 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 123, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper890 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 340, __wbg_adapter_40); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper3218 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1413, __wbg_adapter_43); + return addHeapObject(ret); + }; + imports['./snippets/geng-2e04217e96c54cd9/inline3.js'] = __wbg_star0; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star1; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/crabrave/crabrave.wasm b/examples/crabrave/crabrave.wasm new file mode 100644 index 00000000..65a18160 Binary files /dev/null and b/examples/crabrave/crabrave.wasm differ diff --git a/examples/crabrave/index.html b/examples/crabrave/index.html new file mode 100644 index 00000000..1fb19da7 --- /dev/null +++ b/examples/crabrave/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/crabrave/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/crabrave/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/crabrave/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/crabrave/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/crabrave/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/crabrave/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/crabrave/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/crabrave/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/crabrave/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/crabrave/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/crabrave/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/crabrave/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/crabrave/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/crabrave/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/crabrave/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/crabrave/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/crabrave/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/crabrave/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/crabrave/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/crabrave/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/crabrave/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/crabrave/sound-fix.js b/examples/crabrave/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/crabrave/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/custom_cursor/assets/cursor.png b/examples/custom_cursor/assets/cursor.png new file mode 100644 index 00000000..4dfadc8e Binary files /dev/null and b/examples/custom_cursor/assets/cursor.png differ diff --git a/examples/custom_cursor/custom_cursor.js b/examples/custom_cursor/custom_cursor.js new file mode 100644 index 00000000..0174a672 --- /dev/null +++ b/examples/custom_cursor/custom_cursor.js @@ -0,0 +1,1354 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_28(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h76e0e5452829c3cc(arg0, arg1, addHeapObject(arg2)); +} + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_33(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hff33a4d3e057942c(arg0, arg1); +} + +function __wbg_adapter_42(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h37e6fa24344e4d87(arg0, arg1, addHeapObject(arg2)); +} + +function __wbg_adapter_45(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_372(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_is_object = function(arg0) { + const val = getObject(arg0); + const ret = typeof(val) === 'object' && val !== null; + return ret; + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_getReader_ab94afcb5cb7689a = function() { return handleError(function (arg0) { + const ret = getObject(arg0).getReader(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_done_2ffa852272310e47 = function(arg0) { + const ret = getObject(arg0).done; + return ret; + }; + imports.wbg.__wbg_value_9f6eeb1e2aab8d96 = function(arg0) { + const ret = getObject(arg0).value; + return addHeapObject(ret); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_fetch_5aed618e85a9cc28 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).fetch(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_read_e7d0f8a49be01d86 = function(arg0) { + const ret = getObject(arg0).read(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_releaseLock_5c49db976c08b864 = function(arg0) { + getObject(arg0).releaseLock(); + }; + imports.wbg.__wbg_cancel_6ee33d4006737aef = function(arg0) { + const ret = getObject(arg0).cancel(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_status_61a01141acd3cf74 = function(arg0) { + const ret = getObject(arg0).status; + return ret; + }; + imports.wbg.__wbg_body_9545a94f397829db = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_toString_c816a20ab859d0c1 = function(arg0) { + const ret = getObject(arg0).toString(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_372(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_catch_0260e338d10f79ae = function(arg0, arg1) { + const ret = getObject(arg0).catch(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_a73caa9a87991566 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).then(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) { + const ret = new Uint8Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper268 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 44, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper270 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 44, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper272 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 44, __wbg_adapter_33); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper274 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 44, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper276 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 44, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper278 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 44, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper6498 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 2487, __wbg_adapter_42); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper6588 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 2529, __wbg_adapter_45); + return addHeapObject(ret); + }; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star0; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/custom_cursor/custom_cursor.wasm b/examples/custom_cursor/custom_cursor.wasm new file mode 100644 index 00000000..d115cdb8 Binary files /dev/null and b/examples/custom_cursor/custom_cursor.wasm differ diff --git a/examples/custom_cursor/index.html b/examples/custom_cursor/index.html new file mode 100644 index 00000000..318b735a --- /dev/null +++ b/examples/custom_cursor/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/custom_cursor/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/custom_cursor/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/custom_cursor/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/custom_cursor/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/custom_cursor/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/custom_cursor/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/custom_cursor/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/custom_cursor/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/custom_cursor/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/custom_cursor/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/custom_cursor/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/custom_cursor/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/custom_cursor/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/custom_cursor/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/custom_cursor/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/custom_cursor/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/custom_cursor/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/custom_cursor/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/custom_cursor/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/custom_cursor/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/custom_cursor/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/custom_cursor/sound-fix.js b/examples/custom_cursor/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/custom_cursor/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/custom_font_shader/custom_font_shader.js b/examples/custom_font_shader/custom_font_shader.js new file mode 100644 index 00000000..ebb2e0f5 --- /dev/null +++ b/examples/custom_font_shader/custom_font_shader.js @@ -0,0 +1,1307 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-2e04217e96c54cd9/inline3.js'; +import * as __wbg_star1 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_26(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0a24fcf62c1e014b(arg0, arg1, addHeapObject(arg2)); +} + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_37(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf185e2e5d56e05ee(arg0, arg1); +} + +function __wbg_adapter_40(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_357(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_performance_3298a9628a5c8aa4 = function(arg0) { + const ret = getObject(arg0).performance; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_activeTexture_5f084e1b3f14853e = function(arg0, arg1) { + getObject(arg0).activeTexture(arg1 >>> 0); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_width_aee8b8809b033b05 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_now_4e659b3d15f470d9 = function(arg0) { + const ret = getObject(arg0).now(); + return ret; + }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_357(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper238 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 38, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper240 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 38, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper242 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 38, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper244 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 38, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper246 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 38, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper248 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 38, __wbg_adapter_37); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper3089 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1324, __wbg_adapter_40); + return addHeapObject(ret); + }; + imports['./snippets/geng-2e04217e96c54cd9/inline3.js'] = __wbg_star0; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star1; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/custom_font_shader/custom_font_shader.wasm b/examples/custom_font_shader/custom_font_shader.wasm new file mode 100644 index 00000000..b7bd41fb Binary files /dev/null and b/examples/custom_font_shader/custom_font_shader.wasm differ diff --git a/examples/custom_font_shader/index.html b/examples/custom_font_shader/index.html new file mode 100644 index 00000000..97835f6a --- /dev/null +++ b/examples/custom_font_shader/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/custom_font_shader/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/custom_font_shader/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/custom_font_shader/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/custom_font_shader/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/custom_font_shader/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/custom_font_shader/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/custom_font_shader/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/custom_font_shader/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/custom_font_shader/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/custom_font_shader/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/custom_font_shader/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/custom_font_shader/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/custom_font_shader/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/custom_font_shader/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/custom_font_shader/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/custom_font_shader/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/custom_font_shader/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/custom_font_shader/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/custom_font_shader/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/custom_font_shader/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/custom_font_shader/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/custom_font_shader/sound-fix.js b/examples/custom_font_shader/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/custom_font_shader/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/derive-assets/assets/list/1.txt b/examples/derive-assets/assets/list/1.txt new file mode 100644 index 00000000..156511ae --- /dev/null +++ b/examples/derive-assets/assets/list/1.txt @@ -0,0 +1 @@ +text1 \ No newline at end of file diff --git a/examples/derive-assets/assets/list/2.txt b/examples/derive-assets/assets/list/2.txt new file mode 100644 index 00000000..009b64ba --- /dev/null +++ b/examples/derive-assets/assets/list/2.txt @@ -0,0 +1 @@ +text2 \ No newline at end of file diff --git a/examples/derive-assets/assets/list/3.txt b/examples/derive-assets/assets/list/3.txt new file mode 100644 index 00000000..1f7857bd --- /dev/null +++ b/examples/derive-assets/assets/list/3.txt @@ -0,0 +1 @@ +text3 \ No newline at end of file diff --git a/examples/derive-assets/assets/list/list.json b/examples/derive-assets/assets/list/list.json new file mode 100644 index 00000000..f7421b5d --- /dev/null +++ b/examples/derive-assets/assets/list/list.json @@ -0,0 +1,5 @@ +[ + "1", + "2", + "3" +] \ No newline at end of file diff --git a/examples/derive-assets/derive-assets.js b/examples/derive-assets/derive-assets.js new file mode 100644 index 00000000..a2d1af8f --- /dev/null +++ b/examples/derive-assets/derive-assets.js @@ -0,0 +1,1354 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_28(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h73c424ee1ff1f3b3(arg0, arg1, addHeapObject(arg2)); +} + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_37(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h66895e0417f9e83b(arg0, arg1); +} + +function __wbg_adapter_42(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h37e6fa24344e4d87(arg0, arg1, addHeapObject(arg2)); +} + +function __wbg_adapter_45(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_372(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_is_object = function(arg0) { + const val = getObject(arg0); + const ret = typeof(val) === 'object' && val !== null; + return ret; + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_getReader_ab94afcb5cb7689a = function() { return handleError(function (arg0) { + const ret = getObject(arg0).getReader(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_done_2ffa852272310e47 = function(arg0) { + const ret = getObject(arg0).done; + return ret; + }; + imports.wbg.__wbg_value_9f6eeb1e2aab8d96 = function(arg0) { + const ret = getObject(arg0).value; + return addHeapObject(ret); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_fetch_5aed618e85a9cc28 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).fetch(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_read_e7d0f8a49be01d86 = function(arg0) { + const ret = getObject(arg0).read(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_releaseLock_5c49db976c08b864 = function(arg0) { + getObject(arg0).releaseLock(); + }; + imports.wbg.__wbg_cancel_6ee33d4006737aef = function(arg0) { + const ret = getObject(arg0).cancel(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_status_61a01141acd3cf74 = function(arg0) { + const ret = getObject(arg0).status; + return ret; + }; + imports.wbg.__wbg_body_9545a94f397829db = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_toString_c816a20ab859d0c1 = function(arg0) { + const ret = getObject(arg0).toString(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_372(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_catch_0260e338d10f79ae = function(arg0, arg1) { + const ret = getObject(arg0).catch(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_a73caa9a87991566 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).then(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) { + const ret = new Uint8Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper428 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 147, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper430 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 147, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper432 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 147, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper434 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 147, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper436 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 147, __wbg_adapter_37); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper438 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 147, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper2988 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1403, __wbg_adapter_42); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper3078 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1446, __wbg_adapter_45); + return addHeapObject(ret); + }; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star0; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/derive-assets/derive-assets.wasm b/examples/derive-assets/derive-assets.wasm new file mode 100644 index 00000000..deb5988b Binary files /dev/null and b/examples/derive-assets/derive-assets.wasm differ diff --git a/examples/derive-assets/index.html b/examples/derive-assets/index.html new file mode 100644 index 00000000..ad9d3f5d --- /dev/null +++ b/examples/derive-assets/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/derive-assets/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/derive-assets/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/derive-assets/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/derive-assets/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/derive-assets/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/derive-assets/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/derive-assets/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/derive-assets/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/derive-assets/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/derive-assets/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/derive-assets/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/derive-assets/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/derive-assets/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/derive-assets/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/derive-assets/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/derive-assets/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/derive-assets/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/derive-assets/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/derive-assets/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/derive-assets/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/derive-assets/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/derive-assets/sound-fix.js b/examples/derive-assets/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/derive-assets/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/draw/assets/texture.png b/examples/draw/assets/texture.png new file mode 100644 index 00000000..917e4fd0 Binary files /dev/null and b/examples/draw/assets/texture.png differ diff --git a/examples/draw/draw.js b/examples/draw/draw.js new file mode 100644 index 00000000..f864e507 --- /dev/null +++ b/examples/draw/draw.js @@ -0,0 +1,1340 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { setup_image } from './snippets/geng-asset-dc4ee02ddfcc1509/inline0.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-2e04217e96c54cd9/inline3.js'; +import * as __wbg_star1 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_26(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h06b081c1b443eaf8(arg0, arg1, addHeapObject(arg2)); +} + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_31(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb0295b2b451abfab(arg0, arg1); +} + +function __wbg_adapter_40(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5de5bed9ca3e124a(arg0, arg1, arg2); +} + +function __wbg_adapter_43(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_374(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_setupimage_eedb9c1b6f90a78f = function(arg0, arg1) { + setup_image(getObject(arg0), takeObject(arg1)); + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_performance_3298a9628a5c8aa4 = function(arg0) { + const ret = getObject(arg0).performance; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_texImage2D_067ff4b1e817ef37 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4 >>> 0, arg5 >>> 0, getObject(arg6)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_activeTexture_5f084e1b3f14853e = function(arg0, arg1) { + getObject(arg0).activeTexture(arg1 >>> 0); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_generateMipmap_cd6c5ba2828aac7e = function(arg0, arg1) { + getObject(arg0).generateMipmap(arg1 >>> 0); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_width_aee8b8809b033b05 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_now_4e659b3d15f470d9 = function(arg0) { + const ret = getObject(arg0).now(); + return ret; + }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_setsrc_681ceacdf6845f60 = function(arg0, arg1, arg2) { + getObject(arg0).src = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_width_59e0563d9c871704 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_1a892edafac94d49 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_new_e6ce9457ca710f38 = function() { return handleError(function () { + const ret = new Image(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_374(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper402 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 123, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper404 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 123, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper406 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 123, __wbg_adapter_31); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper408 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 123, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper410 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 123, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper412 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 123, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper1027 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 391, __wbg_adapter_40); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper3356 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1464, __wbg_adapter_43); + return addHeapObject(ret); + }; + imports['./snippets/geng-2e04217e96c54cd9/inline3.js'] = __wbg_star0; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star1; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/draw/draw.wasm b/examples/draw/draw.wasm new file mode 100644 index 00000000..87a0ceba Binary files /dev/null and b/examples/draw/draw.wasm differ diff --git a/examples/draw/index.html b/examples/draw/index.html new file mode 100644 index 00000000..da29dbdb --- /dev/null +++ b/examples/draw/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/draw/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/draw/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/draw/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/draw/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/draw/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/draw/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/draw/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/draw/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/draw/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/draw/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/draw/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/draw/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/draw/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/draw/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/draw/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/draw/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/draw/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/draw/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/draw/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/draw/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/draw/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/draw/sound-fix.js b/examples/draw/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/draw/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/gltf/assets/crab.glb b/examples/gltf/assets/crab.glb new file mode 100644 index 00000000..7cf830b5 Binary files /dev/null and b/examples/gltf/assets/crab.glb differ diff --git a/examples/gltf/assets/shader.glsl b/examples/gltf/assets/shader.glsl new file mode 100644 index 00000000..cc9b288f --- /dev/null +++ b/examples/gltf/assets/shader.glsl @@ -0,0 +1,187 @@ +// https://github.com/bwasty/gltf-viewer/blob/master/src/shaders + +varying vec2 v_uv; +varying vec2 v_mr_uv; +varying vec4 v_color; +varying vec3 v_normal; +varying vec3 v_world_pos; + +vec3 vec4_to_3(vec4 v) { + return v.xyz / v.w; +} + +#ifdef VERTEX_SHADER + +attribute vec2 a_uv; +attribute vec2 a_mr_uv; +attribute vec3 a_pos; +attribute vec3 a_normal; +attribute vec4 a_color; + +uniform mat4 u_projection_matrix; +uniform mat4 u_view_matrix; +uniform mat4 u_model_matrix; + +void main() { + v_uv = a_uv; + v_mr_uv = a_mr_uv; + v_color = a_color; + v_world_pos = vec4_to_3(u_model_matrix * vec4(a_pos, 1.0)); + v_normal = normalize(vec3(u_model_matrix * vec4(a_normal, 0.0))); + gl_Position = u_projection_matrix * u_view_matrix * vec4(v_world_pos, 1.0); +} +#endif + +#ifdef FRAGMENT_SHADER + +uniform sampler2D u_base_color_texture; +uniform vec4 u_base_color_factor; +uniform sampler2D u_metallic_roughness_texture; +uniform float u_metallic_factor; +uniform float u_roughness_factor; + +uniform vec3 u_eye_pos; +uniform vec3 u_light_dir; +uniform vec4 u_light_color; +uniform vec4 u_ambient_light_color; +uniform float u_ambient_light_intensity; + +// Encapsulate the various inputs used by the various functions in the shading equation +// We store values in this struct to simplify the integration of alternative implementations +// of the shading terms, outlined in the Readme.MD Appendix. +struct PBRInfo +{ + float NdotL; // cos angle between normal and light direction + float NdotV; // cos angle between normal and view direction + float NdotH; // cos angle between normal and half vector + float LdotH; // cos angle between light direction and half vector + float VdotH; // cos angle between view direction and half vector + float perceptualRoughness; // roughness value, as authored by the model creator (input to shader) + float metalness; // metallic value at the surface + vec3 reflectance0; // full reflectance color (normal incidence angle) + vec3 reflectance90; // reflectance color at grazing angle + float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2]) + vec3 diffuseColor; // color contribution from diffuse lighting + vec3 specularColor; // color contribution from specular lighting +}; + +const float M_PI = 3.141592653589793; +const float c_MinRoughness = 0.04; + +// Basic Lambertian diffuse +// Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog +// See also [1], Equation 1 +vec3 diffuse(PBRInfo pbrInputs) +{ + return pbrInputs.diffuseColor / M_PI; +} + +// The following equation models the Fresnel reflectance term of the spec equation (aka F()) +// Implementation of fresnel from [4], Equation 15 +vec3 specularReflection(PBRInfo pbrInputs) +{ + return pbrInputs.reflectance0 + (pbrInputs.reflectance90 - pbrInputs.reflectance0) * pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0); +} + +// This calculates the specular geometric attenuation (aka G()), +// where rougher material will reflect less light back to the viewer. +// This implementation is based on [1] Equation 4, and we adopt their modifications to +// alphaRoughness as input as originally proposed in [2]. +float geometricOcclusion(PBRInfo pbrInputs) +{ + float NdotL = pbrInputs.NdotL; + float NdotV = pbrInputs.NdotV; + float r = pbrInputs.alphaRoughness; + + float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL))); + float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV))); + return attenuationL * attenuationV; +} + +// The following equation(s) model the distribution of microfacet normals across the area being drawn (aka D()) +// Implementation from "Average Irregularity Representation of a Roughened Surface for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz +// Follows the distribution function recommended in the SIGGRAPH 2013 course notes from EPIC Games [1], Equation 3. +float microfacetDistribution(PBRInfo pbrInputs) +{ + float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness; + float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0; + return roughnessSq / (M_PI * f * f); +} + +void main() { + vec4 mr_sample = texture2D(u_metallic_roughness_texture, v_mr_uv); + float perceptualRoughness = mr_sample.g * u_roughness_factor; + float metallic = mr_sample.b * u_metallic_factor; + vec4 base_color = texture2D(u_base_color_texture, v_uv) * u_base_color_factor * v_color; + + float alphaRoughness = perceptualRoughness * perceptualRoughness; + + vec3 f0 = vec3(0.04); + vec3 diffuseColor = base_color.rgb * (vec3(1.0) - f0); + diffuseColor *= 1.0 - metallic; + vec3 specularColor = mix(f0, base_color.rgb, metallic); + + // Compute reflectance. + float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b); + + // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect. + // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflecance to 0%. + float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); + vec3 specularEnvironmentR0 = specularColor.rgb; + vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; + + vec3 n = v_normal; /*getNormal();*/ // normal at surface point + vec3 v = normalize(u_eye_pos - v_world_pos); // Vector from surface point to camera + vec3 l = normalize(u_light_dir); // Vector from surface point to light + vec3 h = normalize(l+v); // Half vector between both l and v + vec3 reflection = -normalize(reflect(v, n)); + + float NdotL = clamp(dot(n, l), 0.001, 1.0); + float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0); + float NdotH = clamp(dot(n, h), 0.0, 1.0); + float LdotH = clamp(dot(l, h), 0.0, 1.0); + float VdotH = clamp(dot(v, h), 0.0, 1.0); + + PBRInfo pbrInputs = PBRInfo( + NdotL, + NdotV, + NdotH, + LdotH, + VdotH, + perceptualRoughness, + metallic, + specularEnvironmentR0, + specularEnvironmentR90, + alphaRoughness, + diffuseColor, + specularColor + ); + + // Calculate the shading terms for the microfacet specular shading model + vec3 F = specularReflection(pbrInputs); + float G = geometricOcclusion(pbrInputs); + float D = microfacetDistribution(pbrInputs); + + // Calculation of analytical lighting contribution + vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs); + vec3 specContrib = F * G * D / (4.0 * NdotL * NdotV); + vec3 color = NdotL * u_light_color.rgb * (diffuseContrib + specContrib); + + color += u_ambient_light_color.rgb * u_ambient_light_intensity * base_color.xyz; + + // NOTE: the spec mandates to ignore any alpha value in 'OPAQUE' mode + // float alpha = mix(1.0, base_color.a, u_AlphaBlend); + // if (u_AlphaCutoff > 0.0) { + // alpha = step(u_AlphaCutoff, base_color.a); + // } + + // if (alpha == 0.0) { + // discard; + // } + float alpha = 1.0; + + // TODO!: apply fix from reference shader: + // https://github.com/KhronosGroup/glTF-WebGL-PBR/pull/55/files#diff-f7232333b020880432a925d5a59e075d + gl_FragColor = vec4(color, alpha); +} +#endif \ No newline at end of file diff --git a/examples/gltf/gltf.js b/examples/gltf/gltf.js new file mode 100644 index 00000000..bf2c3a80 --- /dev/null +++ b/examples/gltf/gltf.js @@ -0,0 +1,1448 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { set_progress_title } from './snippets/geng-2e04217e96c54cd9/inline1.js'; +import { set_progress } from './snippets/geng-2e04217e96c54cd9/inline2.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-2e04217e96c54cd9/inline3.js'; +import * as __wbg_star1 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_28(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h239373f073e5231d(arg0, arg1, addHeapObject(arg2)); +} + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_37(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfff8e41d2763453e(arg0, arg1); +} + +function __wbg_adapter_42(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h37e6fa24344e4d87(arg0, arg1, addHeapObject(arg2)); +} + +function __wbg_adapter_45(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_420(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_setprogresstitle_4939642f7ce61aad = function(arg0, arg1) { + set_progress_title(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_setprogress_ed975deecdf64347 = function(arg0, arg1, arg2) { + set_progress(arg0, arg1 === 0 ? undefined : arg2); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_is_object = function(arg0) { + const val = getObject(arg0); + const ret = typeof(val) === 'object' && val !== null; + return ret; + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_getReader_ab94afcb5cb7689a = function() { return handleError(function (arg0) { + const ret = getObject(arg0).getReader(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_done_2ffa852272310e47 = function(arg0) { + const ret = getObject(arg0).done; + return ret; + }; + imports.wbg.__wbg_value_9f6eeb1e2aab8d96 = function(arg0) { + const ret = getObject(arg0).value; + return addHeapObject(ret); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_location_2951b5ee34f19221 = function(arg0) { + const ret = getObject(arg0).location; + return addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_performance_3298a9628a5c8aa4 = function(arg0) { + const ret = getObject(arg0).performance; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_fetch_5aed618e85a9cc28 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).fetch(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_exitPointerLock_b62fe3c7830470e4 = function(arg0) { + getObject(arg0).exitPointerLock(); + }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_requestPointerLock_78b2a4a24cb69366 = function(arg0) { + getObject(arg0).requestPointerLock(); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_setonchange_8f887c27a2d4469d = function(arg0, arg1) { + getObject(arg0).onchange = getObject(arg1); + }; + imports.wbg.__wbg_click_897b305b2e10b9cf = function(arg0) { + getObject(arg0).click(); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_activeTexture_5f084e1b3f14853e = function(arg0, arg1) { + getObject(arg0).activeTexture(arg1 >>> 0); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_get_58f6d5f6aee3f846 = function(arg0, arg1) { + const ret = getObject(arg0)[arg1 >>> 0]; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_read_e7d0f8a49be01d86 = function(arg0) { + const ret = getObject(arg0).read(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_releaseLock_5c49db976c08b864 = function(arg0) { + getObject(arg0).releaseLock(); + }; + imports.wbg.__wbg_cancel_6ee33d4006737aef = function(arg0) { + const ret = getObject(arg0).cancel(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_files_8b6e6eff43af0f6d = function(arg0) { + const ret = getObject(arg0).files; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_settype_12715bd23e119883 = function(arg0, arg1, arg2) { + getObject(arg0).type = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_href_706b235ecfe6848c = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg1).href; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_newwithu8arraysequence_9d62f79f4425e877 = function() { return handleError(function (arg0) { + const ret = new Blob(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_stream_a1bf63efd5be11ab = function(arg0) { + const ret = getObject(arg0).stream(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_width_aee8b8809b033b05 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_now_4e659b3d15f470d9 = function(arg0) { + const ret = getObject(arg0).now(); + return ret; + }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_status_61a01141acd3cf74 = function(arg0) { + const ret = getObject(arg0).status; + return ret; + }; + imports.wbg.__wbg_body_9545a94f397829db = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_setdownload_65ac7e7c800d764e = function(arg0, arg1, arg2) { + getObject(arg0).download = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_href_40fd5bca11c13133 = function(arg0, arg1) { + const ret = getObject(arg1).href; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_sethref_b0712139dd35e2fd = function(arg0, arg1, arg2) { + getObject(arg0).href = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_createObjectURL_ad8244759309f204 = function() { return handleError(function (arg0, arg1) { + const ret = URL.createObjectURL(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }, arguments) }; + imports.wbg.__wbg_revokeObjectURL_16a2051ee9d99da9 = function() { return handleError(function (arg0, arg1) { + URL.revokeObjectURL(getStringFromWasm0(arg0, arg1)); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_of_4a2b313a453ec059 = function(arg0) { + const ret = Array.of(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_toString_c816a20ab859d0c1 = function(arg0) { + const ret = getObject(arg0).toString(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_420(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_catch_0260e338d10f79ae = function(arg0, arg1) { + const ret = getObject(arg0).catch(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_a73caa9a87991566 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).then(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) { + const ret = new Uint8Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper291 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 6, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper293 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 6, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper295 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 6, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper297 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 6, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper299 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 6, __wbg_adapter_37); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper301 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 6, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper7885 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 2909, __wbg_adapter_42); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper7975 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 2951, __wbg_adapter_45); + return addHeapObject(ret); + }; + imports['./snippets/geng-2e04217e96c54cd9/inline3.js'] = __wbg_star0; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star1; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/gltf/gltf.wasm b/examples/gltf/gltf.wasm new file mode 100644 index 00000000..ad320865 Binary files /dev/null and b/examples/gltf/gltf.wasm differ diff --git a/examples/gltf/index.html b/examples/gltf/index.html new file mode 100644 index 00000000..3784ffd8 --- /dev/null +++ b/examples/gltf/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/gltf/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/gltf/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/gltf/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/gltf/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/gltf/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/gltf/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/gltf/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/gltf/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/gltf/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/gltf/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/gltf/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/gltf/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/gltf/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/gltf/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/gltf/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/gltf/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/gltf/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/gltf/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/gltf/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/gltf/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/gltf/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/gltf/sound-fix.js b/examples/gltf/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/gltf/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/hello_world/hello_world.js b/examples/hello_world/hello_world.js new file mode 100644 index 00000000..eed35203 --- /dev/null +++ b/examples/hello_world/hello_world.js @@ -0,0 +1,1297 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_26(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h4401722666c82748(arg0, arg1, addHeapObject(arg2)); +} + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_37(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hd12dcd25ae812886(arg0, arg1); +} + +function __wbg_adapter_40(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_351(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_activeTexture_5f084e1b3f14853e = function(arg0, arg1) { + getObject(arg0).activeTexture(arg1 >>> 0); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_width_aee8b8809b033b05 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_351(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper250 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 40, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper252 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 40, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper254 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 40, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper256 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 40, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper258 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 40, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper260 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 40, __wbg_adapter_37); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper2714 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1171, __wbg_adapter_40); + return addHeapObject(ret); + }; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star0; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/hello_world/hello_world.wasm b/examples/hello_world/hello_world.wasm new file mode 100644 index 00000000..5b5e0c1e Binary files /dev/null and b/examples/hello_world/hello_world.wasm differ diff --git a/examples/hello_world/index.html b/examples/hello_world/index.html new file mode 100644 index 00000000..5cb93339 --- /dev/null +++ b/examples/hello_world/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/hello_world/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/hello_world/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/hello_world/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/hello_world/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/hello_world/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/hello_world/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/hello_world/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/hello_world/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/hello_world/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/hello_world/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/hello_world/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/hello_world/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/hello_world/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/hello_world/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/hello_world/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/hello_world/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/hello_world/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/hello_world/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/hello_world/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/hello_world/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/hello_world/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/hello_world/sound-fix.js b/examples/hello_world/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/hello_world/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/index.html b/examples/index.html new file mode 100644 index 00000000..11c5d2ef --- /dev/null +++ b/examples/index.html @@ -0,0 +1,10 @@ +geng
\ No newline at end of file diff --git a/examples/line_texture/assets/texture.png b/examples/line_texture/assets/texture.png new file mode 100644 index 00000000..f497d04c Binary files /dev/null and b/examples/line_texture/assets/texture.png differ diff --git a/examples/line_texture/index.html b/examples/line_texture/index.html new file mode 100644 index 00000000..5ef92ed0 --- /dev/null +++ b/examples/line_texture/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/line_texture/line_texture.js b/examples/line_texture/line_texture.js new file mode 100644 index 00000000..adba6571 --- /dev/null +++ b/examples/line_texture/line_texture.js @@ -0,0 +1,1340 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { setup_image } from './snippets/geng-asset-dc4ee02ddfcc1509/inline0.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-2e04217e96c54cd9/inline3.js'; +import * as __wbg_star1 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_26(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h17e645b710bec2e6(arg0, arg1, addHeapObject(arg2)); +} + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_33(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hbb78b57d03f70d99(arg0, arg1); +} + +function __wbg_adapter_40(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5de5bed9ca3e124a(arg0, arg1, arg2); +} + +function __wbg_adapter_43(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_374(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_setupimage_eedb9c1b6f90a78f = function(arg0, arg1) { + setup_image(getObject(arg0), takeObject(arg1)); + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_performance_3298a9628a5c8aa4 = function(arg0) { + const ret = getObject(arg0).performance; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_texImage2D_067ff4b1e817ef37 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4 >>> 0, arg5 >>> 0, getObject(arg6)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_activeTexture_5f084e1b3f14853e = function(arg0, arg1) { + getObject(arg0).activeTexture(arg1 >>> 0); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_generateMipmap_cd6c5ba2828aac7e = function(arg0, arg1) { + getObject(arg0).generateMipmap(arg1 >>> 0); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_width_aee8b8809b033b05 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_now_4e659b3d15f470d9 = function(arg0) { + const ret = getObject(arg0).now(); + return ret; + }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_setsrc_681ceacdf6845f60 = function(arg0, arg1, arg2) { + getObject(arg0).src = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_width_59e0563d9c871704 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_1a892edafac94d49 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_new_e6ce9457ca710f38 = function() { return handleError(function () { + const ret = new Image(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_374(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper409 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 99, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper411 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 99, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper413 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 99, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper415 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 99, __wbg_adapter_33); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper417 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 99, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper419 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 99, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper896 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 347, __wbg_adapter_40); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper3224 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1420, __wbg_adapter_43); + return addHeapObject(ret); + }; + imports['./snippets/geng-2e04217e96c54cd9/inline3.js'] = __wbg_star0; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star1; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/line_texture/line_texture.wasm b/examples/line_texture/line_texture.wasm new file mode 100644 index 00000000..debb1df0 Binary files /dev/null and b/examples/line_texture/line_texture.wasm differ diff --git a/examples/line_texture/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/line_texture/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/line_texture/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/line_texture/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/line_texture/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/line_texture/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/line_texture/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/line_texture/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/line_texture/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/line_texture/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/line_texture/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/line_texture/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/line_texture/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/line_texture/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/line_texture/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/line_texture/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/line_texture/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/line_texture/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/line_texture/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/line_texture/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/line_texture/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/line_texture/sound-fix.js b/examples/line_texture/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/line_texture/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/pong/index.html b/examples/pong/index.html new file mode 100644 index 00000000..5f3a6541 --- /dev/null +++ b/examples/pong/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/pong/pong.js b/examples/pong/pong.js new file mode 100644 index 00000000..485bb6cc --- /dev/null +++ b/examples/pong/pong.js @@ -0,0 +1,1358 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-2e04217e96c54cd9/inline3.js'; +import * as __wbg_star1 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_30(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1f1718d672b67846(arg0, arg1, addHeapObject(arg2)); +} + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_37(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5ea0593f8dd82b60(arg0, arg1); +} + +function __wbg_adapter_44(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_377(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_is_object = function(arg0) { + const val = getObject(arg0); + const ret = typeof(val) === 'object' && val !== null; + return ret; + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_performance_3298a9628a5c8aa4 = function(arg0) { + const ret = getObject(arg0).performance; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_activeTexture_5f084e1b3f14853e = function(arg0, arg1) { + getObject(arg0).activeTexture(arg1 >>> 0); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_width_aee8b8809b033b05 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_now_4e659b3d15f470d9 = function(arg0) { + const ret = getObject(arg0).now(); + return ret; + }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_crypto_1d1f22824a6a080c = function(arg0) { + const ret = getObject(arg0).crypto; + return addHeapObject(ret); + }; + imports.wbg.__wbg_process_4a72847cc503995b = function(arg0) { + const ret = getObject(arg0).process; + return addHeapObject(ret); + }; + imports.wbg.__wbg_versions_f686565e586dd935 = function(arg0) { + const ret = getObject(arg0).versions; + return addHeapObject(ret); + }; + imports.wbg.__wbg_node_104a2ff8d6ea03a2 = function(arg0) { + const ret = getObject(arg0).node; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_string = function(arg0) { + const ret = typeof(getObject(arg0)) === 'string'; + return ret; + }; + imports.wbg.__wbg_require_cca90b1a94a0255b = function() { return handleError(function () { + const ret = module.require; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_msCrypto_eb05e62b530a1508 = function(arg0) { + const ret = getObject(arg0).msCrypto; + return addHeapObject(ret); + }; + imports.wbg.__wbg_randomFillSync_5c9c955aa56b6049 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).randomFillSync(takeObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_getRandomValues_3aa56aa6edec874c = function() { return handleError(function (arg0, arg1) { + getObject(arg0).getRandomValues(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_377(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) { + const ret = new Uint8Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_newwithlength_e9b4878cebadb3d3 = function(arg0) { + const ret = new Uint8Array(arg0 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_subarray_a1f73cd4b5b42fe1 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper215 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 3, __wbg_adapter_30); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper217 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 3, __wbg_adapter_30); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper219 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 3, __wbg_adapter_30); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper221 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 3, __wbg_adapter_37); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper223 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 3, __wbg_adapter_30); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper225 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 3, __wbg_adapter_30); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper3129 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1327, __wbg_adapter_44); + return addHeapObject(ret); + }; + imports['./snippets/geng-2e04217e96c54cd9/inline3.js'] = __wbg_star0; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star1; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/pong/pong.wasm b/examples/pong/pong.wasm new file mode 100644 index 00000000..2b0222eb Binary files /dev/null and b/examples/pong/pong.wasm differ diff --git a/examples/pong/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/pong/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/pong/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/pong/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/pong/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/pong/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/pong/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/pong/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/pong/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/pong/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/pong/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/pong/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/pong/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/pong/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/pong/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/pong/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/pong/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/pong/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/pong/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/pong/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/pong/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/pong/sound-fix.js b/examples/pong/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/pong/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/sound/assets/hello.wav b/examples/sound/assets/hello.wav new file mode 100644 index 00000000..3b84bc2a Binary files /dev/null and b/examples/sound/assets/hello.wav differ diff --git a/examples/sound/assets/music.mp3 b/examples/sound/assets/music.mp3 new file mode 100644 index 00000000..4fe7d642 Binary files /dev/null and b/examples/sound/assets/music.mp3 differ diff --git a/examples/sound/index.html b/examples/sound/index.html new file mode 100644 index 00000000..3b82b684 --- /dev/null +++ b/examples/sound/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/sound/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/sound/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/sound/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/sound/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/sound/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/sound/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/sound/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/sound/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/sound/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/sound/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/sound/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/sound/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/sound/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/sound/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/sound/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/sound/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/sound/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/sound/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/sound/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/sound/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/sound/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/sound/sound-fix.js b/examples/sound/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/sound/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/sound/sound.js b/examples/sound/sound.js new file mode 100644 index 00000000..c4944fd0 --- /dev/null +++ b/examples/sound/sound.js @@ -0,0 +1,1421 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { PlaybackPositionNode } from './snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_28(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0c6c9b808dce1052(arg0, arg1, addHeapObject(arg2)); +} + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_37(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hcbcf7e2e38f79234(arg0, arg1); +} + +function __wbg_adapter_42(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h37e6fa24344e4d87(arg0, arg1, addHeapObject(arg2)); +} + +function __wbg_adapter_45(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_408(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_new_748b2bacb2e9d569 = function(arg0) { + const ret = new PlaybackPositionNode(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_start_ebd8c4e3386533be = function(arg0, arg1, arg2) { + getObject(arg0).start(arg1, arg2); + }; + imports.wbg.__wbg_stop_a4b7304fd93ab9cc = function(arg0, arg1) { + getObject(arg0).stop(arg1); + }; + imports.wbg.__wbg_setloop_408b8189d62d1a2e = function(arg0, arg1) { + getObject(arg0).loop = arg1 !== 0; + }; + imports.wbg.__wbg_setbuffer_a9ab34ac826d42b9 = function(arg0, arg1) { + getObject(arg0).buffer = getObject(arg1); + }; + imports.wbg.__wbg_playbackRate_ae397dd911294ece = function(arg0) { + const ret = getObject(arg0).playbackRate; + return addHeapObject(ret); + }; + imports.wbg.__wbg_playbackPosition_d24181166ee2ccd5 = function(arg0) { + const ret = getObject(arg0).playbackPosition; + return ret; + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_is_object = function(arg0) { + const val = getObject(arg0); + const ret = typeof(val) === 'object' && val !== null; + return ret; + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_getReader_ab94afcb5cb7689a = function() { return handleError(function (arg0) { + const ret = getObject(arg0).getReader(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_done_2ffa852272310e47 = function(arg0) { + const ret = getObject(arg0).done; + return ret; + }; + imports.wbg.__wbg_value_9f6eeb1e2aab8d96 = function(arg0) { + const ret = getObject(arg0).value; + return addHeapObject(ret); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_fetch_5aed618e85a9cc28 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).fetch(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_activeTexture_5f084e1b3f14853e = function(arg0, arg1) { + getObject(arg0).activeTexture(arg1 >>> 0); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_read_e7d0f8a49be01d86 = function(arg0) { + const ret = getObject(arg0).read(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_releaseLock_5c49db976c08b864 = function(arg0) { + getObject(arg0).releaseLock(); + }; + imports.wbg.__wbg_cancel_6ee33d4006737aef = function(arg0) { + const ret = getObject(arg0).cancel(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_context_35d0c1e43bbe21c3 = function(arg0) { + const ret = getObject(arg0).context; + return addHeapObject(ret); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_width_aee8b8809b033b05 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_duration_d0efd334f02cff58 = function(arg0) { + const ret = getObject(arg0).duration; + return ret; + }; + imports.wbg.__wbg_currentTime_9659d7a7455ef95f = function(arg0) { + const ret = getObject(arg0).currentTime; + return ret; + }; + imports.wbg.__wbg_gain_992e52c27fe23f6b = function(arg0) { + const ret = getObject(arg0).gain; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_status_61a01141acd3cf74 = function(arg0) { + const ret = getObject(arg0).status; + return ret; + }; + imports.wbg.__wbg_body_9545a94f397829db = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_setvalue_386ea64eb220ce1c = function(arg0, arg1) { + getObject(arg0).value = arg1; + }; + imports.wbg.__wbg_cancelScheduledValues_762ff8f6aaf10346 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).cancelScheduledValues(arg1); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_linearRampToValueAtTime_e88770a6b173b85e = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).linearRampToValueAtTime(arg1, arg2); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_currentTime_9bc85e1579050a3f = function(arg0) { + const ret = getObject(arg0).currentTime; + return ret; + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_decodeAudioData_6e4a09d9bdf064dc = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).decodeAudioData(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_toString_c816a20ab859d0c1 = function(arg0) { + const ret = getObject(arg0).toString(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_408(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_catch_0260e338d10f79ae = function(arg0, arg1) { + const ret = getObject(arg0).catch(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_a73caa9a87991566 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).then(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) { + const ret = new Uint8Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper282 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 41, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper284 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 41, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper286 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 41, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper288 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 41, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper290 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 41, __wbg_adapter_37); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper292 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 41, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper2813 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1218, __wbg_adapter_42); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper2903 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1261, __wbg_adapter_45); + return addHeapObject(ret); + }; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star0; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/sound/sound.wasm b/examples/sound/sound.wasm new file mode 100644 index 00000000..e3acfbe5 Binary files /dev/null and b/examples/sound/sound.wasm differ diff --git a/examples/text_input/index.html b/examples/text_input/index.html new file mode 100644 index 00000000..82edcf4e --- /dev/null +++ b/examples/text_input/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/text_input/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/text_input/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/text_input/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/text_input/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/text_input/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/text_input/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/text_input/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/text_input/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/text_input/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/text_input/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/text_input/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/text_input/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/text_input/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/text_input/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/text_input/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/text_input/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/text_input/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/text_input/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/text_input/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/text_input/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/text_input/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/text_input/sound-fix.js b/examples/text_input/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/text_input/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/text_input/text_input.js b/examples/text_input/text_input.js new file mode 100644 index 00000000..b235e08f --- /dev/null +++ b/examples/text_input/text_input.js @@ -0,0 +1,1307 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-2e04217e96c54cd9/inline3.js'; +import * as __wbg_star1 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_26(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h06ef95115833ca4a(arg0, arg1, addHeapObject(arg2)); +} + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_31(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h492524001d1a9360(arg0, arg1); +} + +function __wbg_adapter_40(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_357(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_performance_3298a9628a5c8aa4 = function(arg0) { + const ret = getObject(arg0).performance; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_activeTexture_5f084e1b3f14853e = function(arg0, arg1) { + getObject(arg0).activeTexture(arg1 >>> 0); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_width_aee8b8809b033b05 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_now_4e659b3d15f470d9 = function(arg0) { + const ret = getObject(arg0).now(); + return ret; + }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_357(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper296 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 59, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper298 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 59, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper300 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 59, __wbg_adapter_31); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper302 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 59, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper304 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 59, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper306 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 59, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper3079 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1326, __wbg_adapter_40); + return addHeapObject(ret); + }; + imports['./snippets/geng-2e04217e96c54cd9/inline3.js'] = __wbg_star0; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star1; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/text_input/text_input.wasm b/examples/text_input/text_input.wasm new file mode 100644 index 00000000..72e2461c Binary files /dev/null and b/examples/text_input/text_input.wasm differ diff --git a/examples/transparent/index.html b/examples/transparent/index.html new file mode 100644 index 00000000..ec5b654d --- /dev/null +++ b/examples/transparent/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/transparent/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/transparent/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/transparent/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/transparent/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/transparent/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/transparent/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/transparent/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/transparent/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/transparent/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/transparent/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/transparent/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/transparent/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/transparent/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/transparent/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/transparent/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/transparent/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/transparent/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/transparent/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/transparent/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/transparent/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/transparent/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/transparent/sound-fix.js b/examples/transparent/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/transparent/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/transparent/transparent.js b/examples/transparent/transparent.js new file mode 100644 index 00000000..88dee8d1 --- /dev/null +++ b/examples/transparent/transparent.js @@ -0,0 +1,1307 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-2e04217e96c54cd9/inline3.js'; +import * as __wbg_star1 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_26(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hc5a717f6a5ef48a2(arg0, arg1); +} + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_29(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h03ca8a3674e27760(arg0, arg1, addHeapObject(arg2)); +} + +function __wbg_adapter_40(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_357(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_performance_3298a9628a5c8aa4 = function(arg0) { + const ret = getObject(arg0).performance; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_activeTexture_5f084e1b3f14853e = function(arg0, arg1) { + getObject(arg0).activeTexture(arg1 >>> 0); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_width_aee8b8809b033b05 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_now_4e659b3d15f470d9 = function(arg0) { + const ret = getObject(arg0).now(); + return ret; + }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_357(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper342 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 71, __wbg_adapter_26); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper344 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 71, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper346 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 71, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper348 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 71, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper350 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 71, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper352 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 71, __wbg_adapter_29); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper3073 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1324, __wbg_adapter_40); + return addHeapObject(ret); + }; + imports['./snippets/geng-2e04217e96c54cd9/inline3.js'] = __wbg_star0; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star1; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/transparent/transparent.wasm b/examples/transparent/transparent.wasm new file mode 100644 index 00000000..0655f350 Binary files /dev/null and b/examples/transparent/transparent.wasm differ diff --git a/examples/ui/assets/shader.glsl b/examples/ui/assets/shader.glsl new file mode 100644 index 00000000..0c7d845e --- /dev/null +++ b/examples/ui/assets/shader.glsl @@ -0,0 +1,27 @@ +varying vec2 v_vt; + +#ifdef VERTEX_SHADER +attribute vec2 a_pos; +uniform mat3 u_projection_matrix; +uniform mat3 u_view_matrix; +uniform vec2 u_pos; +uniform vec2 u_size; + +void main() { + v_vt = a_pos; + vec2 world_pos = u_pos + u_size * a_pos; + vec3 pos = u_projection_matrix * u_view_matrix * vec3(world_pos, 1.0); + gl_Position = vec4(pos.xy, 0.0, pos.z); +} +#endif + +#ifdef FRAGMENT_SHADER +uniform float u_ratio; +uniform sampler2D u_texture; +void main() { + gl_FragColor = texture2D(u_texture, v_vt); + if (v_vt.y < u_ratio) { + gl_FragColor *= vec4(1.0, 0.0, 0.0, 1.0); + } +} +#endif \ No newline at end of file diff --git a/examples/ui/assets/texture.png b/examples/ui/assets/texture.png new file mode 100644 index 00000000..c07fd4f4 Binary files /dev/null and b/examples/ui/assets/texture.png differ diff --git a/examples/ui/index.html b/examples/ui/index.html new file mode 100644 index 00000000..45e5aef2 --- /dev/null +++ b/examples/ui/index.html @@ -0,0 +1,167 @@ + + + + + + + + + + + + + +
+
+

Loading wasm

+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/examples/ui/snippets/geng-2e04217e96c54cd9/inline0.js b/examples/ui/snippets/geng-2e04217e96c54cd9/inline0.js new file mode 100644 index 00000000..73acf49f --- /dev/null +++ b/examples/ui/snippets/geng-2e04217e96c54cd9/inline0.js @@ -0,0 +1,8 @@ + + export function show_error(text) { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "none"; + document.getElementById("error-message").textContent = text; + document.getElementById("geng-error-screen").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/ui/snippets/geng-2e04217e96c54cd9/inline1.js b/examples/ui/snippets/geng-2e04217e96c54cd9/inline1.js new file mode 100644 index 00000000..80e0cdca --- /dev/null +++ b/examples/ui/snippets/geng-2e04217e96c54cd9/inline1.js @@ -0,0 +1,5 @@ + + export function set_progress_title(title) { + window.gengUpdateProgressTitle(title); + } + \ No newline at end of file diff --git a/examples/ui/snippets/geng-2e04217e96c54cd9/inline2.js b/examples/ui/snippets/geng-2e04217e96c54cd9/inline2.js new file mode 100644 index 00000000..1a56ee79 --- /dev/null +++ b/examples/ui/snippets/geng-2e04217e96c54cd9/inline2.js @@ -0,0 +1,5 @@ + + export function set_progress(progress, total) { + window.gengUpdateProgress(progress, total); + } + \ No newline at end of file diff --git a/examples/ui/snippets/geng-2e04217e96c54cd9/inline3.js b/examples/ui/snippets/geng-2e04217e96c54cd9/inline3.js new file mode 100644 index 00000000..09072843 --- /dev/null +++ b/examples/ui/snippets/geng-2e04217e96c54cd9/inline3.js @@ -0,0 +1,6 @@ + + export function finish_loading() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; + } + \ No newline at end of file diff --git a/examples/ui/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js b/examples/ui/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js new file mode 100644 index 00000000..13068266 --- /dev/null +++ b/examples/ui/snippets/geng-asset-dc4ee02ddfcc1509/inline0.js @@ -0,0 +1,6 @@ + + export function setup_image(image, handler) { + image.onload = function() { handler(true); }; + image.onerror = function() { handler(false); }; + } + \ No newline at end of file diff --git a/examples/ui/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js b/examples/ui/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js new file mode 100644 index 00000000..e07d7152 --- /dev/null +++ b/examples/ui/snippets/geng-web-audio-api-bcae241db5b207e7/src/platform/PlaybackPositionNode.js @@ -0,0 +1,105 @@ +// Based on https://github.com/kurtsmurf/whirly/blob/master/src/PlaybackPositionNode.js + +// playback position hack: +// https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-459514360 + +// composite audio node: +// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode + +// extends the interface of AudioBufferSourceNode with a `playbackPosition` property +export class PlaybackPositionNode { + constructor(context) { + this.context = context; + + // initialize component audio nodes + this._bufferSource = new AudioBufferSourceNode(context); + this._splitter = new ChannelSplitterNode(context); + this._out = new ChannelMergerNode(context); + this._sampleHolder = new Float32Array(1); + } + + // get current progress between 0 and 1 + get playbackPosition() { + this._analyser?.getFloatTimeDomainData(this._sampleHolder); + return this._sampleHolder[0]; + } + + // creates an AudioBuffer with an extra `position` track + set buffer(audioBuffer) { + // create a new AudioBuffer of the same length as param with one extra channel + // load it into the AudioBufferSourceNode + const bufferWithTimeData = new AudioBuffer({ + length: audioBuffer.length, + sampleRate: audioBuffer.sampleRate, + numberOfChannels: audioBuffer.numberOfChannels + 1, + }); + + // copy data from the audioBuffer arg to our new AudioBuffer + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + bufferWithTimeData.copyToChannel( + audioBuffer.getChannelData(index), + index, + ); + } + + // fill up the position channel with numbers from 0 to duration (in seconds) + // most performant implementation to create the big array is via "for" + // https://stackoverflow.com/a/53029824 + const length = audioBuffer.length; + const timeDataArray = new Float32Array(length); + const duration = audioBuffer.duration; + for (let i = 0; i < length; i++) { + timeDataArray[i] = i * duration / length; + } + bufferWithTimeData.copyToChannel( + timeDataArray, + audioBuffer.numberOfChannels, + ); + + // Has to be after data was changed according to this comment: + // https://github.com/WebAudio/web-audio-api/issues/2397#issuecomment-1887161919 + this._bufferSource.buffer = bufferWithTimeData; + + // split the channels + this._bufferSource.connect(this._splitter); + + // connect all the audio channels to the line out + for (let index = 0; index < audioBuffer.numberOfChannels; index++) { + this._splitter.connect(this._out, index, index); + } + + // connect the position channel to an analyzer so we can extract position data + this._analyser = new AnalyserNode(this.context); + this._splitter.connect(this._analyser, audioBuffer.numberOfChannels); + } + + // forward component node properties + + get loop() { + return this._bufferSource.loop; + } + + set loop(val) { + this._bufferSource.loop = val; + } + + get playbackRate() { + return this._bufferSource.playbackRate; + } + + start(...args) { + this._bufferSource.start(...args); + } + + stop(...args) { + this._bufferSource.stop(...args); + } + + connect(...args) { + this._out.connect(...args); + } + + disconnect(...args) { + this._out.disconnect(...args); + } +} \ No newline at end of file diff --git a/examples/ui/snippets/geng-window-db03662d38a1cf07/src/backend/web.js b/examples/ui/snippets/geng-window-db03662d38a1cf07/src/backend/web.js new file mode 100644 index 00000000..2f387d91 --- /dev/null +++ b/examples/ui/snippets/geng-window-db03662d38a1cf07/src/backend/web.js @@ -0,0 +1,85 @@ +export function initialize_window(canvas) { + window.GENG_CANVAS_SCALE = 1.0; + canvas.tabIndex = -1; + function update() { + canvas.width = Math.floor(canvas.clientWidth * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + canvas.height = Math.floor(canvas.clientHeight * window.devicePixelRatio * window.GENG_CANVAS_SCALE); + + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + screen.lockOrientationUniversal = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation; + if (screen.lockOrientationUniversal) { + screen.lockOrientationUniversal("landscape"); + } else { + try { + screen.orientation.lock("landscape").catch(function () { + }); + } catch (e) { } + } + } else { + screen.unlockOrientationUniversal = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation; + if (screen.unlockOrientationUniversal) { + screen.unlockOrientationUniversal(); + } else { + try { + screen.orientation.unlock(); + } catch (e) { } + } + } + }; + window.setInterval(update, 100); + update(); +} + +export function is_fullscreen() { + var document = window.document; + if (document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement) { + return true; + } else { + return false; + } +} + +export function set_fullscreen(elem, fullscreen) { + if (fullscreen) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } + } else { + var document = window.document; + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } +} + +export function show() { + document.getElementById("geng-progress-screen").style.display = "none"; + document.getElementById("geng-canvas").style.display = "block"; +} + +export function request_animation_frame_loop(f) { + function loop() { + f(); + requestAnimationFrame(loop); + } + loop(); +} \ No newline at end of file diff --git a/examples/ui/sound-fix.js b/examples/ui/sound-fix.js new file mode 100644 index 00000000..40db7245 --- /dev/null +++ b/examples/ui/sound-fix.js @@ -0,0 +1,62 @@ +// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab: +// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward + +// the following function keeps track of all AudioContexts and resumes them on the first user +// interaction with the page. If the function is called and all contexts are already running, +// it will remove itself from all event listeners. +(function () { + // An array of all contexts to resume on the page + const audioContextList = []; + + // An array of various user interaction events we should listen for + const userInputEventNames = [ + "click", + "contextmenu", + "auxclick", + "dblclick", + "mousedown", + "mouseup", + "pointerup", + "touchend", + "keydown", + "keyup", + ]; + + // A proxy object to intercept AudioContexts and + // add them to the array for tracking and resuming later + self.AudioContext = new Proxy(self.AudioContext, { + construct(target, args) { + const result = new target(...args); + audioContextList.push(result); + return result; + }, + }); + + // To resume all AudioContexts being tracked + function resumeAllContexts(_event) { + let count = 0; + + audioContextList.forEach((context) => { + if (context.state !== "running") { + context.resume(); + } else { + count++; + } + }); + + // If all the AudioContexts have now resumed then we unbind all + // the event listeners from the page to prevent unnecessary resume attempts + // Checking count > 0 ensures that the user interaction happens AFTER the game started up + if (count > 0 && count === audioContextList.length) { + userInputEventNames.forEach((eventName) => { + document.removeEventListener(eventName, resumeAllContexts); + }); + } + } + + // We bind the resume function for each user interaction + // event on the page + userInputEventNames.forEach((eventName) => { + document.addEventListener(eventName, resumeAllContexts); + }); +})(); \ No newline at end of file diff --git a/examples/ui/ui.js b/examples/ui/ui.js new file mode 100644 index 00000000..3a160cfa --- /dev/null +++ b/examples/ui/ui.js @@ -0,0 +1,1404 @@ +import { show_error } from './snippets/geng-2e04217e96c54cd9/inline0.js'; +import { setup_image } from './snippets/geng-asset-dc4ee02ddfcc1509/inline0.js'; +import { initialize_window, request_animation_frame_loop } from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; +import * as __wbg_star0 from './snippets/geng-2e04217e96c54cd9/inline3.js'; +import * as __wbg_star1 from './snippets/geng-window-db03662d38a1cf07/src/backend/web.js'; + +const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined)); +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) +}); + +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_28(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e196b4bf596c7f1(arg0, arg1, addHeapObject(arg2)); +} + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_33(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h81598b47143ea353(arg0, arg1); +} + +function __wbg_adapter_42(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5de5bed9ca3e124a(arg0, arg1, arg2); +} + +function __wbg_adapter_45(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h37e6fa24344e4d87(arg0, arg1, addHeapObject(arg2)); +} + +function __wbg_adapter_48(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1e92ad545f27fbeb(arg0, arg1, addHeapObject(arg2)); +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedFloat32Memory0 = null; + +function getFloat32Memory0() { + if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) { + cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer); + } + return cachedFloat32Memory0; +} + +function getArrayF32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len); +} +function __wbg_adapter_399(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d93b1d9b519af0a(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingByteSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingByteSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingbytesource_free(ptr); + } + /** + * @returns {string} + */ + get type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.intounderlyingbytesource_type(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {number} + */ + get autoAllocateChunkSize() { + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @param {ReadableByteStreamController} controller + */ + start(controller) { + wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller)); + } + /** + * @param {ReadableByteStreamController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingbytesource_cancel(ptr); + } +} + +const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSink { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSinkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsink_free(ptr); + } + /** + * @param {any} chunk + * @returns {Promise} + */ + write(chunk) { + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk)); + return takeObject(ret); + } + /** + * @returns {Promise} + */ + close() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_close(ptr); + return takeObject(ret); + } + /** + * @param {any} reason + * @returns {Promise} + */ + abort(reason) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason)); + return takeObject(ret); + } +} + +const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0)); +/** +*/ +export class IntoUnderlyingSource { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IntoUnderlyingSourceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_intounderlyingsource_free(ptr); + } + /** + * @param {ReadableStreamDefaultController} controller + * @returns {Promise} + */ + pull(controller) { + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller)); + return takeObject(ret); + } + /** + */ + cancel() { + const ptr = this.__destroy_into_raw(); + wasm.intounderlyingsource_cancel(ptr); + } +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_showerror_0d91a1c5a4527659 = function(arg0, arg1) { + show_error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }; + imports.wbg.__wbindgen_cb_drop = function(arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; + }; + imports.wbg.__wbg_setupimage_eedb9c1b6f90a78f = function(arg0, arg1) { + setup_image(getObject(arg0), takeObject(arg1)); + }; + imports.wbg.__wbg_initializewindow_fa5eb8eb6cab009a = function(arg0) { + initialize_window(getObject(arg0)); + }; + imports.wbg.__wbg_requestanimationframeloop_011e7f0b58562722 = function(arg0) { + request_animation_frame_loop(getObject(arg0)); + }; + imports.wbg.__wbindgen_is_object = function(arg0) { + const val = getObject(arg0); + const ret = typeof(val) === 'object' && val !== null; + return ret; + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_log_ab36f137277a9db1 = function(arg0, arg1) { + console.log(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_getReader_ab94afcb5cb7689a = function() { return handleError(function (arg0) { + const ret = getObject(arg0).getReader(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_done_2ffa852272310e47 = function(arg0) { + const ret = getObject(arg0).done; + return ret; + }; + imports.wbg.__wbg_value_9f6eeb1e2aab8d96 = function(arg0) { + const ret = getObject(arg0).value; + return addHeapObject(ret); + }; + imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) { + queueMicrotask(getObject(arg0)); + }; + imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_document_5100775d18896c16 = function(arg0) { + const ret = getObject(arg0).document; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_devicePixelRatio_efc553b59506f64c = function(arg0) { + const ret = getObject(arg0).devicePixelRatio; + return ret; + }; + imports.wbg.__wbg_performance_3298a9628a5c8aa4 = function(arg0) { + const ret = getObject(arg0).performance; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_fetch_5aed618e85a9cc28 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).fetch(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_body_edb1908d3ceff3a1 = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_pointerLockElement_571dbde6150f0fa5 = function(arg0) { + const ret = getObject(arg0).pointerLockElement; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createElement_8bae7856a4bb7411 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getElementById_c369ff43f0db99cf = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getBoundingClientRect_91e6d57c4e65f745 = function(arg0) { + const ret = getObject(arg0).getBoundingClientRect(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_sethidden_1da7d3202cfe66f3 = function(arg0, arg1) { + getObject(arg0).hidden = arg1 !== 0; + }; + imports.wbg.__wbg_style_c3fc3dd146182a2d = function(arg0) { + const ret = getObject(arg0).style; + return addHeapObject(ret); + }; + imports.wbg.__wbg_focus_39d4b8ba8ff9df14 = function() { return handleError(function (arg0) { + getObject(arg0).focus(); + }, arguments) }; + imports.wbg.__wbg_instanceof_WebGlRenderingContext_d48361eb1e636d9a = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebGLRenderingContext; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_bufferData_d37ea06bddbb0e15 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0); + }; + imports.wbg.__wbg_bufferSubData_235dee7535344996 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_texImage2D_e7b9786b49257799 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10)); + }, arguments) }; + imports.wbg.__wbg_texImage2D_067ff4b1e817ef37 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4 >>> 0, arg5 >>> 0, getObject(arg6)); + }, arguments) }; + imports.wbg.__wbg_uniformMatrix2fv_4417ed4d88a140be = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix2fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix3fv_d46553a1248946b5 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix3fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_uniformMatrix4fv_cd46ed81bccb0cb2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4)); + }; + imports.wbg.__wbg_activeTexture_5f084e1b3f14853e = function(arg0, arg1) { + getObject(arg0).activeTexture(arg1 >>> 0); + }; + imports.wbg.__wbg_attachShader_6397dc4fd87343d3 = function(arg0, arg1, arg2) { + getObject(arg0).attachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_bindBuffer_1e5043751efddd4f = function(arg0, arg1, arg2) { + getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindFramebuffer_c301d73a2c2842bb = function(arg0, arg1, arg2) { + getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindRenderbuffer_8ec7d02bd60bdfb2 = function(arg0, arg1, arg2) { + getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_bindTexture_772f5eb022019d87 = function(arg0, arg1, arg2) { + getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2)); + }; + imports.wbg.__wbg_blendEquationSeparate_721f30ba584a5233 = function(arg0, arg1, arg2) { + getObject(arg0).blendEquationSeparate(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_blendFuncSeparate_abe2ad4272c8365e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_checkFramebufferStatus_2380be4caf464ead = function(arg0, arg1) { + const ret = getObject(arg0).checkFramebufferStatus(arg1 >>> 0); + return ret; + }; + imports.wbg.__wbg_clear_f9731a47df2e70d8 = function(arg0, arg1) { + getObject(arg0).clear(arg1 >>> 0); + }; + imports.wbg.__wbg_clearColor_42707553c40e0e0f = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).clearColor(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_clearDepth_42ac48f2ab25c419 = function(arg0, arg1) { + getObject(arg0).clearDepth(arg1); + }; + imports.wbg.__wbg_clearStencil_0f906e2d8b61aa7a = function(arg0, arg1) { + getObject(arg0).clearStencil(arg1); + }; + imports.wbg.__wbg_colorMask_03aa359acc86fd70 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).colorMask(arg1 !== 0, arg2 !== 0, arg3 !== 0, arg4 !== 0); + }; + imports.wbg.__wbg_compileShader_3af4719dfdb508e3 = function(arg0, arg1) { + getObject(arg0).compileShader(getObject(arg1)); + }; + imports.wbg.__wbg_createBuffer_34e01f5c10929b41 = function(arg0) { + const ret = getObject(arg0).createBuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createFramebuffer_49ca64e9e1c6f5eb = function(arg0) { + const ret = getObject(arg0).createFramebuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createProgram_9affbfa62b7b2608 = function(arg0) { + const ret = getObject(arg0).createProgram(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createRenderbuffer_375d7f4004bc49bd = function(arg0) { + const ret = getObject(arg0).createRenderbuffer(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createShader_55ca04b44164bd41 = function(arg0, arg1) { + const ret = getObject(arg0).createShader(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_createTexture_c13c31b2b132c17f = function(arg0) { + const ret = getObject(arg0).createTexture(); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_cullFace_af37bb1c2d22ab73 = function(arg0, arg1) { + getObject(arg0).cullFace(arg1 >>> 0); + }; + imports.wbg.__wbg_deleteBuffer_96df38349e3487d2 = function(arg0, arg1) { + getObject(arg0).deleteBuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteFramebuffer_417b62b6156d4894 = function(arg0, arg1) { + getObject(arg0).deleteFramebuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteProgram_641402f7551587d8 = function(arg0, arg1) { + getObject(arg0).deleteProgram(getObject(arg1)); + }; + imports.wbg.__wbg_deleteRenderbuffer_d3aedb394b1ea546 = function(arg0, arg1) { + getObject(arg0).deleteRenderbuffer(getObject(arg1)); + }; + imports.wbg.__wbg_deleteShader_e5c778f25b722e68 = function(arg0, arg1) { + getObject(arg0).deleteShader(getObject(arg1)); + }; + imports.wbg.__wbg_deleteTexture_f89d8e417b156960 = function(arg0, arg1) { + getObject(arg0).deleteTexture(getObject(arg1)); + }; + imports.wbg.__wbg_depthFunc_1ee4bf1e0127bf7f = function(arg0, arg1) { + getObject(arg0).depthFunc(arg1 >>> 0); + }; + imports.wbg.__wbg_depthMask_dd6cd8a9aff90e5c = function(arg0, arg1) { + getObject(arg0).depthMask(arg1 !== 0); + }; + imports.wbg.__wbg_detachShader_2be0011a543a788a = function(arg0, arg1, arg2) { + getObject(arg0).detachShader(getObject(arg1), getObject(arg2)); + }; + imports.wbg.__wbg_disable_5dd8c3842de93e92 = function(arg0, arg1) { + getObject(arg0).disable(arg1 >>> 0); + }; + imports.wbg.__wbg_disableVertexAttribArray_12bc9adefa738796 = function(arg0, arg1) { + getObject(arg0).disableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_drawArrays_f619a26a53ab5ab3 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3); + }; + imports.wbg.__wbg_enable_7abe812a71c76206 = function(arg0, arg1) { + getObject(arg0).enable(arg1 >>> 0); + }; + imports.wbg.__wbg_enableVertexAttribArray_6d44444aa994f42a = function(arg0, arg1) { + getObject(arg0).enableVertexAttribArray(arg1 >>> 0); + }; + imports.wbg.__wbg_framebufferRenderbuffer_e1c9c64aea848b39 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4)); + }; + imports.wbg.__wbg_framebufferTexture2D_66e1968fd5b7b3e3 = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5); + }; + imports.wbg.__wbg_generateMipmap_cd6c5ba2828aac7e = function(arg0, arg1) { + getObject(arg0).generateMipmap(arg1 >>> 0); + }; + imports.wbg.__wbg_getActiveAttrib_0750343119e6d917 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveAttrib(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getActiveUniform_eed3c598e3e75d14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getActiveUniform(getObject(arg1), arg2 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_getAttribLocation_0a3d71a11394d043 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return ret; + }; + imports.wbg.__wbg_getError_fd1f7b2b2ba5a860 = function(arg0) { + const ret = getObject(arg0).getError(); + return ret; + }; + imports.wbg.__wbg_getExtension_cb7fb87e4bca59c7 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getParameter_a77768abe8a51f24 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).getParameter(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_getProgramInfoLog_bf1fba8fa90667c7 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getProgramInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getProgramParameter_10c8a43809fb8c2e = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getShaderInfoLog_0262cb299092ce92 = function(arg0, arg1, arg2) { + const ret = getObject(arg1).getShaderInfoLog(getObject(arg2)); + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getShaderParameter_60b69083e8d662ce = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniform_de84e29f4c5207ae = function(arg0, arg1, arg2) { + const ret = getObject(arg0).getUniform(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getUniformLocation_6eedfb513ccce732 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_lineWidth_dbfe6d243b93c325 = function(arg0, arg1) { + getObject(arg0).lineWidth(arg1); + }; + imports.wbg.__wbg_linkProgram_af5fed9dc3f1cdf9 = function(arg0, arg1) { + getObject(arg0).linkProgram(getObject(arg1)); + }; + imports.wbg.__wbg_pixelStorei_054e50b5fdc17824 = function(arg0, arg1, arg2) { + getObject(arg0).pixelStorei(arg1 >>> 0, arg2); + }; + imports.wbg.__wbg_renderbufferStorage_f41b3c99f6a8f25e = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4); + }; + imports.wbg.__wbg_shaderSource_7891a1fcb69a0023 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3)); + }; + imports.wbg.__wbg_stencilFuncSeparate_a3699f92e69c1494 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3, arg4 >>> 0); + }; + imports.wbg.__wbg_stencilOpSeparate_321604240216c55c = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0); + }; + imports.wbg.__wbg_texParameteri_d1035ed45d6c5655 = function(arg0, arg1, arg2, arg3) { + getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3); + }; + imports.wbg.__wbg_uniform1f_8914cb45b3ad5887 = function(arg0, arg1, arg2) { + getObject(arg0).uniform1f(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform1i_badd5ff70c0d30bf = function(arg0, arg1, arg2) { + getObject(arg0).uniform1i(getObject(arg1), arg2); + }; + imports.wbg.__wbg_uniform2f_dbf02e46dd8c211d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2f(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform2i_120bae772bfe743d = function(arg0, arg1, arg2, arg3) { + getObject(arg0).uniform2i(getObject(arg1), arg2, arg3); + }; + imports.wbg.__wbg_uniform3f_866e96669df4a3d2 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3f(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform3i_545b62c9aca2f834 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).uniform3i(getObject(arg1), arg2, arg3, arg4); + }; + imports.wbg.__wbg_uniform4f_fb56c7f4de64dd4c = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4f(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_uniform4i_8b5d01ce77adc20e = function(arg0, arg1, arg2, arg3, arg4, arg5) { + getObject(arg0).uniform4i(getObject(arg1), arg2, arg3, arg4, arg5); + }; + imports.wbg.__wbg_useProgram_c637e43f9cd4c07a = function(arg0, arg1) { + getObject(arg0).useProgram(getObject(arg1)); + }; + imports.wbg.__wbg_vertexAttribPointer_c25e4c5ed17f8a1d = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { + getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6); + }; + imports.wbg.__wbg_viewport_221ade2aef6032c8 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).viewport(arg1, arg2, arg3, arg4); + }; + imports.wbg.__wbg_repeat_f64b916c6eed0685 = function(arg0) { + const ret = getObject(arg0).repeat; + return ret; + }; + imports.wbg.__wbg_code_3b0c3912a2351163 = function(arg0, arg1) { + const ret = getObject(arg1).code; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_byobRequest_72fca99f9c32c193 = function(arg0) { + const ret = getObject(arg0).byobRequest; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_close_184931724d961ccc = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_changedTouches_d044c818dbcb83b1 = function(arg0) { + const ret = getObject(arg0).changedTouches; + return addHeapObject(ret); + }; + imports.wbg.__wbg_offsetX_1a40c03298c0d8b6 = function(arg0) { + const ret = getObject(arg0).offsetX; + return ret; + }; + imports.wbg.__wbg_offsetY_f75e8c25b9d9b679 = function(arg0) { + const ret = getObject(arg0).offsetY; + return ret; + }; + imports.wbg.__wbg_button_367cdc7303e3cf9b = function(arg0) { + const ret = getObject(arg0).button; + return ret; + }; + imports.wbg.__wbg_movementX_b800a0cacd14d9bf = function(arg0) { + const ret = getObject(arg0).movementX; + return ret; + }; + imports.wbg.__wbg_movementY_7907e03eb8c0ea1e = function(arg0) { + const ret = getObject(arg0).movementY; + return ret; + }; + imports.wbg.__wbg_read_e7d0f8a49be01d86 = function(arg0) { + const ret = getObject(arg0).read(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_releaseLock_5c49db976c08b864 = function(arg0) { + getObject(arg0).releaseLock(); + }; + imports.wbg.__wbg_cancel_6ee33d4006737aef = function(arg0) { + const ret = getObject(arg0).cancel(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_instanceof_HtmlInputElement_307512fe1252c849 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_setautofocus_5ef4f6fab60cacbf = function(arg0, arg1) { + getObject(arg0).autofocus = arg1 !== 0; + }; + imports.wbg.__wbg_setsize_1e19966d9fce167e = function(arg0, arg1) { + getObject(arg0).size = arg1 >>> 0; + }; + imports.wbg.__wbg_value_47fe6384562f52ab = function(arg0, arg1) { + const ret = getObject(arg1).value; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_setvalue_78cb4f1fef58ae98 = function(arg0, arg1, arg2) { + getObject(arg0).value = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_connect_186433827476e7d8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).connect(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_view_7f0ce470793a340f = function(arg0) { + const ret = getObject(arg0).view; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_respond_b1a43b2e3a06d525 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).respond(arg1 >>> 0); + }, arguments) }; + imports.wbg.__wbg_instanceof_HtmlCanvasElement_46bdbf323b0b18d1 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_width_aee8b8809b033b05 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_80053d3c71b338e0 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_getContext_fec464290556673c = function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3)); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_now_4e659b3d15f470d9 = function(arg0) { + const ret = getObject(arg0).now(); + return ret; + }; + imports.wbg.__wbg_length_679e0f1f9f0744bd = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_item_2b1028b3d39463e9 = function(arg0, arg1) { + const ret = getObject(arg0).item(arg1 >>> 0); + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f70d50e69f3ef0f = function() { return handleError(function (arg0) { + const ret = new GainNode(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_size_c65dc0ea96919b30 = function(arg0) { + const ret = getObject(arg0).size; + return ret; + }; + imports.wbg.__wbg_type_482767003bd3054b = function(arg0) { + const ret = getObject(arg0).type; + return ret; + }; + imports.wbg.__wbg_name_6806bde7ef1355ad = function(arg0, arg1) { + const ret = getObject(arg1).name; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_addEventListener_53b787075bd5e003 = function() { return handleError(function (arg0, arg1, arg2, arg3) { + getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3)); + }, arguments) }; + imports.wbg.__wbg_close_a994f9425dab445c = function() { return handleError(function (arg0) { + getObject(arg0).close(); + }, arguments) }; + imports.wbg.__wbg_enqueue_ea194723156c0cc2 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).enqueue(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_status_61a01141acd3cf74 = function(arg0) { + const ret = getObject(arg0).status; + return ret; + }; + imports.wbg.__wbg_body_9545a94f397829db = function(arg0) { + const ret = getObject(arg0).body; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_drawArraysInstancedANGLE_6afae595a484db93 = function(arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4); + }; + imports.wbg.__wbg_vertexAttribDivisorANGLE_b258d7388e466921 = function(arg0, arg1, arg2) { + getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0); + }; + imports.wbg.__wbg_destination_0014df38da590ed6 = function(arg0) { + const ret = getObject(arg0).destination; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_2f044fe84595e924 = function() { return handleError(function () { + const ret = new lAudioContext(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_top_c4e2234a035a3d25 = function(arg0) { + const ret = getObject(arg0).top; + return ret; + }; + imports.wbg.__wbg_left_fe0a839abdd508f4 = function(arg0) { + const ret = getObject(arg0).left; + return ret; + }; + imports.wbg.__wbg_type_c7f33162571befe7 = function(arg0, arg1) { + const ret = getObject(arg1).type; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) { + const ret = getObject(arg0).target; + return isLikeNone(ret) ? 0 : addHeapObject(ret); + }; + imports.wbg.__wbg_preventDefault_b1a4aafc79409429 = function(arg0) { + getObject(arg0).preventDefault(); + }; + imports.wbg.__wbg_setsrc_681ceacdf6845f60 = function(arg0, arg1, arg2) { + getObject(arg0).src = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_width_59e0563d9c871704 = function(arg0) { + const ret = getObject(arg0).width; + return ret; + }; + imports.wbg.__wbg_height_1a892edafac94d49 = function(arg0) { + const ret = getObject(arg0).height; + return ret; + }; + imports.wbg.__wbg_new_e6ce9457ca710f38 = function() { return handleError(function () { + const ret = new Image(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_identifier_02d52b63cc6ddc4d = function(arg0) { + const ret = getObject(arg0).identifier; + return ret; + }; + imports.wbg.__wbg_pageX_fa02f6046f16d09a = function(arg0) { + const ret = getObject(arg0).pageX; + return ret; + }; + imports.wbg.__wbg_pageY_d1a7e78ba5b4cc5c = function(arg0) { + const ret = getObject(arg0).pageY; + return ret; + }; + imports.wbg.__wbg_setProperty_ea7d15a2b591aa97 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + getObject(arg0).setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + }, arguments) }; + imports.wbg.__wbg_appendChild_580ccb11a660db68 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).appendChild(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_deltaY_032e327e216f2b2b = function(arg0) { + const ret = getObject(arg0).deltaY; + return ret; + }; + imports.wbg.__wbg_deltaMode_294b2eaf54047265 = function(arg0) { + const ret = getObject(arg0).deltaMode; + return ret; + }; + imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_toString_c816a20ab859d0c1 = function(arg0) { + const ret = getObject(arg0).toString(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_399(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } + }; + imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_catch_0260e338d10f79ae = function(arg0, arg1) { + const ret = getObject(arg0).catch(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_then_a73caa9a87991566 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).then(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) { + const ret = new Int32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_e3c5a1468be66841 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_58f3db6ca6f7dc3a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) { + const ret = new Uint8Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) { + const ret = new Float32Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_bd975934d1b1fddb = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_d25bbcbc3367f684 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Int32Array_f5ce6bdcd235ec41 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Int32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_buffer_dd7f74bc60f1faab = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_byteLength_58f7b4fab1919d44 = function(arg0) { + const ret = getObject(arg0).byteLength; + return ret; + }; + imports.wbg.__wbg_byteOffset_81d60f7392524f62 = function(arg0) { + const ret = getObject(arg0).byteOffset; + return ret; + }; + imports.wbg.__wbg_instanceof_Float32Array_a3648c42b5c0571c = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Float32Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper340 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 61, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper342 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 61, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper344 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 61, __wbg_adapter_33); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper346 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 61, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper348 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 61, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper350 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 61, __wbg_adapter_28); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper1150 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 553, __wbg_adapter_42); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper3419 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1596, __wbg_adapter_45); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper3509 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 1639, __wbg_adapter_48); + return addHeapObject(ret); + }; + imports['./snippets/geng-2e04217e96c54cd9/inline3.js'] = __wbg_star0; + imports['./snippets/geng-window-db03662d38a1cf07/src/backend/web.js'] = __wbg_star1; + + return imports; +} + +function __wbg_init_memory(imports, maybe_memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedFloat32Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(input) { + if (wasm !== undefined) return wasm; + + + const imports = __wbg_get_imports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await input, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync } +export default __wbg_init; diff --git a/examples/ui/ui.wasm b/examples/ui/ui.wasm new file mode 100644 index 00000000..934ba199 Binary files /dev/null and b/examples/ui/ui.wasm differ diff --git a/index.html b/index.html new file mode 100644 index 00000000..d36f1e01 --- /dev/null +++ b/index.html @@ -0,0 +1 @@ +geng

Geng

Game engine

🚀 See examples

🌐 Works in browser

Compiles to WebAssembly via wasm-bindgen

Open Source

Give it a ⭐ on GitHub

🦀 Rust

is the best programming language ❤️

\ No newline at end of file diff --git a/menus.js b/menus.js new file mode 100644 index 00000000..b350313a --- /dev/null +++ b/menus.js @@ -0,0 +1,172 @@ +/* eslint no-unused-vars:0 no-prototype-builtins:0 */ +(function (window, document) { + 'use strict'; + + // Enable drop-down menus in Pure + // Inspired by YUI3 gallery-simple-menu by Julien LeComte + // [https://github.com/yui/yui3-gallery/blob/master/src/gallery-simple-menu/js/simple-menu.js] + + function PureDropdown(dropdownParent) { + + var PREFIX = 'pure-', + ACTIVE_CLASS_NAME = PREFIX + 'menu-active', + ARIA_ROLE = 'role', + ARIA_HIDDEN = 'aria-hidden', + MENU_OPEN = 0, + MENU_CLOSED = 1, + MENU_ACTIVE_SELECTOR = '.pure-menu-active', + MENU_LINK_SELECTOR = '.pure-menu-link', + MENU_SELECTOR = '.pure-menu-children', + DISMISS_EVENT = (window.hasOwnProperty && + window.hasOwnProperty('ontouchstart')) ? + 'touchstart' : 'mousedown', + + ARROW_KEYS_ENABLED = true, + + ddm = this; // drop down menu + + this._state = MENU_CLOSED; + + this.show = function () { + if (this._state !== MENU_OPEN) { + this._dropdownParent.classList.add(ACTIVE_CLASS_NAME); + this._menu.setAttribute(ARIA_HIDDEN, false); + this._state = MENU_OPEN; + } + }; + + this.hide = function () { + if (this._state !== MENU_CLOSED) { + this._dropdownParent.classList.remove(ACTIVE_CLASS_NAME); + this._menu.setAttribute(ARIA_HIDDEN, true); + this._link.focus(); + this._state = MENU_CLOSED; + } + }; + + this.toggle = function () { + this[this._state === MENU_CLOSED ? 'show' : 'hide'](); + }; + + this.halt = function (e) { + e.stopPropagation(); + e.preventDefault(); + }; + + this._dropdownParent = dropdownParent; + this._link = this._dropdownParent.querySelector(MENU_LINK_SELECTOR); + this._menu = this._dropdownParent.querySelector(MENU_SELECTOR); + this._firstMenuLink = this._menu.querySelector(MENU_LINK_SELECTOR); + + // Set ARIA attributes + this._link.setAttribute('aria-haspopup', 'true'); + this._menu.setAttribute(ARIA_ROLE, 'menu'); + this._menu.setAttribute('aria-labelledby', this._link.getAttribute('id')); + this._menu.setAttribute('aria-hidden', 'true'); + [].forEach.call( + this._menu.querySelectorAll('li'), + function (el) { + el.setAttribute(ARIA_ROLE, 'presentation'); + } + ); + [].forEach.call( + this._menu.querySelectorAll('a'), + function (el) { + el.setAttribute(ARIA_ROLE, 'menuitem'); + } + ); + + // Toggle on click + this._link.addEventListener('click', function (e) { + e.stopPropagation(); + e.preventDefault(); + ddm.toggle(); + }); + + // Keyboard navigation + document.addEventListener('keydown', function (e) { + var currentLink, + previousSibling, + nextSibling, + previousLink, + nextLink; + + // if the menu isn't active, ignore + if (ddm._state !== MENU_OPEN) { + return; + } + + // if the menu is the parent of an open, active submenu, ignore + if (ddm._menu.querySelector(MENU_ACTIVE_SELECTOR)) { + return; + } + + currentLink = ddm._menu.querySelector(':focus'); + + // Dismiss an open menu on ESC + if (e.keyCode === 27) { + /* Esc */ + ddm.halt(e); + ddm.hide(); + } + // Go to the next link on down arrow + else if (ARROW_KEYS_ENABLED && e.keyCode === 40) { + /* Down arrow */ + ddm.halt(e); + // get the nextSibling (an LI) of the current link's LI + nextSibling = (currentLink) ? currentLink.parentNode.nextSibling : null; + // if the nextSibling is a text node (not an element), go to the next one + while (nextSibling && nextSibling.nodeType !== 1) { + nextSibling = nextSibling.nextSibling; + } + nextLink = (nextSibling) ? nextSibling.querySelector('.pure-menu-link') : null; + // if there is no currently focused link, focus the first one + if (!currentLink) { + ddm._menu.querySelector('.pure-menu-link').focus(); + } + else if (nextLink) { + nextLink.focus(); + } + } + // Go to the previous link on up arrow + else if (ARROW_KEYS_ENABLED && e.keyCode === 38) { + /* Up arrow */ + ddm.halt(e); + // get the currently focused link + previousSibling = (currentLink) ? currentLink.parentNode.previousSibling : null; + while (previousSibling && previousSibling.nodeType !== 1) { + previousSibling = previousSibling.previousSibling; + } + previousLink = (previousSibling) ? previousSibling.querySelector('.pure-menu-link') : null; + // if there is no currently focused link, focus the last link + if (!currentLink) { + ddm._menu.querySelector('.pure-menu-item:last-child .pure-menu-link').focus(); + } + // else if there is a previous item, go to the previous item + else if (previousLink) { + previousLink.focus(); + } + } + }); + + // Dismiss an open menu on outside event + document.addEventListener(DISMISS_EVENT, function (e) { + var target = e.target; + if (target !== ddm._link && !ddm._menu.contains(target)) { + ddm.hide(); + ddm._link.blur(); + } + }); + + } + + function initDropdowns() { + var dropdownParents = document.querySelectorAll('.pure-menu-has-children'); + for (var i = 0; i < dropdownParents.length; i++) { + var ddm = new PureDropdown(dropdownParents[i]); + } + } + + initDropdowns(); + +}(this, this.document)); diff --git a/robots.txt b/robots.txt new file mode 100644 index 00000000..af2bda6b --- /dev/null +++ b/robots.txt @@ -0,0 +1,4 @@ +User-agent: * +Disallow: +Allow: / +Sitemap: https://geng.kuviman.com/sitemap.xml diff --git a/sitemap.xml b/sitemap.xml new file mode 100644 index 00000000..dc7ee89d --- /dev/null +++ b/sitemap.xml @@ -0,0 +1,9 @@ + + + + https://geng.kuviman.com/ + + + https://geng.kuviman.com/examples/ + + diff --git a/sus.css b/sus.css new file mode 100644 index 00000000..4dfe637a --- /dev/null +++ b/sus.css @@ -0,0 +1 @@ +.pure-g>div{box-sizing:border-box}.button-demo{border-radius:30px;text-shadow:0 2px 3px #0003;border:3px solid #0003}.splash{width:80%;height:80%;margin:200px auto;text-align:center}@media screen and (min-width: 48em){.splash{width:50%}}.splash h1{text-transform:uppercase;font-size:300%;padding:1em 2em;border-radius:30px;border:10px solid}.splash .subhead{opacity:50%}.features-grid{text-align:center;margin:auto;width:80%}.features-grid .features-grid-unit{padding:1em}