From e965ed809e91079496f5b2d711ceb3e5e7b99f3d Mon Sep 17 00:00:00 2001 From: mattkae Date: Sun, 6 Feb 2022 16:36:56 -0500 Subject: Working softbody simulation --- 2d/softbody/softbody_2/dist/output.js | 118 ++++++++++++++-------------------- 1 file changed, 47 insertions(+), 71 deletions(-) (limited to '2d/softbody/softbody_2/dist/output.js') diff --git a/2d/softbody/softbody_2/dist/output.js b/2d/softbody/softbody_2/dist/output.js index 51df416..4f59242 100644 --- a/2d/softbody/softbody_2/dist/output.js +++ b/2d/softbody/softbody_2/dist/output.js @@ -15,6 +15,9 @@ // can continue to use Module afterwards as well. var Module = typeof Module !== 'undefined' ? Module : {}; +// See https://caniuse.com/mdn-javascript_builtins_object_assign +var objAssign = Object.assign; + // --pre-jses are emitted after the Module integration code, so that they can // refer to Module (if they choose; they can also define Module) // {{PRE_JSES}} @@ -24,17 +27,11 @@ var Module = typeof Module !== 'undefined' ? Module : {}; // we collect those properties and reapply _after_ we configure // the current environment's defaults to avoid having to be so // defensive during initialization. -var moduleOverrides = {}; -var key; -for (key in Module) { - if (Module.hasOwnProperty(key)) { - moduleOverrides[key] = Module[key]; - } -} +var moduleOverrides = objAssign({}, Module); var arguments_ = []; var thisProgram = './this.program'; -var quit_ = function(status, toThrow) { +var quit_ = (status, toThrow) => { throw toThrow; }; @@ -77,15 +74,16 @@ var read_, // this may no longer be needed under node. function logExceptionOnExit(e) { if (e instanceof ExitStatus) return; - var toLog = e; + let toLog = e; if (e && typeof e === 'object' && e.stack) { toLog = [e, e.stack]; } err('exiting due to exception: ' + toLog); } -var nodeFS; +var fs; var nodePath; +var requireNodeFS; if (ENVIRONMENT_IS_NODE) { if (!(typeof process === 'object' && typeof require === 'function')) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)'); @@ -98,11 +96,20 @@ if (ENVIRONMENT_IS_NODE) { // include: node_shell_read.js +requireNodeFS = function() { + // Use nodePath as the indicator for these not being initialized, + // since in some environments a global fs may have already been + // created. + if (!nodePath) { + fs = require('fs'); + nodePath = require('path'); + } +} + read_ = function shell_read(filename, binary) { - if (!nodeFS) nodeFS = require('fs'); - if (!nodePath) nodePath = require('path'); + requireNodeFS(); filename = nodePath['normalize'](filename); - return nodeFS['readFileSync'](filename, binary ? null : 'utf8'); + return fs.readFileSync(filename, binary ? null : 'utf8'); }; readBinary = function readBinary(filename) { @@ -115,10 +122,9 @@ readBinary = function readBinary(filename) { }; readAsync = function readAsync(filename, onload, onerror) { - if (!nodeFS) nodeFS = require('fs'); - if (!nodePath) nodePath = require('path'); + requireNodeFS(); filename = nodePath['normalize'](filename); - nodeFS['readFile'](filename, function(err, data) { + fs.readFile(filename, function(err, data) { if (err) onerror(err); else onload(data.buffer); }); @@ -149,7 +155,7 @@ readAsync = function readAsync(filename, onload, onerror) { // See https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode process['on']('unhandledRejection', function(reason) { throw reason; }); - quit_ = function(status, toThrow) { + quit_ = (status, toThrow) => { if (keepRuntimeAlive()) { process['exitCode'] = status; throw toThrow; @@ -172,7 +178,7 @@ if (ENVIRONMENT_IS_SHELL) { } readBinary = function readBinary(f) { - var data; + let data; if (typeof readbuffer === 'function') { return new Uint8Array(readbuffer(f)); } @@ -182,7 +188,7 @@ if (ENVIRONMENT_IS_SHELL) { }; readAsync = function readAsync(f, onload, onerror) { - setTimeout(function() { onload(readBinary(f)); }, 0); + setTimeout(() => onload(readBinary(f)), 0); }; if (typeof scriptArgs != 'undefined') { @@ -192,7 +198,7 @@ if (ENVIRONMENT_IS_SHELL) { } if (typeof quit === 'function') { - quit_ = function(status, toThrow) { + quit_ = (status, toThrow) => { logExceptionOnExit(toThrow); quit(status); }; @@ -233,7 +239,6 @@ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { // Differentiate the Web Worker from the Node Worker case, as reading must // be done differently. { - // include: web_or_worker_shell_read.js @@ -272,7 +277,7 @@ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { // end include: web_or_worker_shell_read.js } - setWindowTitle = function(title) { document.title = title }; + setWindowTitle = (title) => document.title = title; } else { throw new Error('environment detection error'); @@ -282,11 +287,7 @@ var out = Module['print'] || console.log.bind(console); var err = Module['printErr'] || console.warn.bind(console); // Merge back in the overrides -for (key in moduleOverrides) { - if (moduleOverrides.hasOwnProperty(key)) { - Module[key] = moduleOverrides[key]; - } -} +objAssign(Module, moduleOverrides); // Free the object hierarchy contained in the overrides, this lets the GC // reclaim data used e.g. in memoryInitializerRequest, which is a large typed array. moduleOverrides = null; @@ -396,10 +397,10 @@ function getNativeTypeSize(type) { case 'float': return 4; case 'double': return 8; default: { - if (type[type.length-1] === '*') { + if (type[type.length - 1] === '*') { return POINTER_SIZE; } else if (type[0] === 'i') { - var bits = Number(type.substr(1)); + const bits = Number(type.substr(1)); assert(bits % 8 === 0, 'getNativeTypeSize invalid bits ' + bits + ', type ' + type); return bits / 8; } else { @@ -694,7 +695,7 @@ var EXITSTATUS; /** @type {function(*, string=)} */ function assert(condition, text) { if (!condition) { - abort('Assertion failed: ' + text); + abort('Assertion failed' + (text ? ': ' + text : '')); } } @@ -2095,21 +2096,6 @@ var ASM_CONSTS = { return 0; } - function _emscripten_set_mousedown_callback_on_thread(target, userData, useCapture, callbackfunc, targetThread) { - registerMouseEventCallback(target, userData, useCapture, callbackfunc, 5, "mousedown", targetThread); - return 0; - } - - function _emscripten_set_mousemove_callback_on_thread(target, userData, useCapture, callbackfunc, targetThread) { - registerMouseEventCallback(target, userData, useCapture, callbackfunc, 8, "mousemove", targetThread); - return 0; - } - - function _emscripten_set_mouseup_callback_on_thread(target, userData, useCapture, callbackfunc, targetThread) { - registerMouseEventCallback(target, userData, useCapture, callbackfunc, 6, "mouseup", targetThread); - return 0; - } - function __webgl_enable_ANGLE_instanced_arrays(ctx) { // Extension available in WebGL 1 from Firefox 26 and Google Chrome 30 onwards. Core feature in WebGL 2. var ext = ctx.getExtension('ANGLE_instanced_arrays'); @@ -2449,20 +2435,6 @@ var ASM_CONSTS = { return _emscripten_webgl_do_create_context(a0,a1); } - function _emscripten_webgl_do_get_current_context() { - return GL.currentContext ? GL.currentContext.handle : 0; - } - function _emscripten_webgl_get_current_context( - ) { - return _emscripten_webgl_do_get_current_context(); - } - Module["_emscripten_webgl_get_current_context"] = _emscripten_webgl_get_current_context; - - function _emscripten_webgl_make_context_current(contextHandle) { - var success = GL.makeContextCurrent(contextHandle); - return success ? 0 : -5; - } - Module["_emscripten_webgl_make_context_current"] = _emscripten_webgl_make_context_current; function _emscripten_webgl_destroy_context(contextHandle) { if (GL.currentContext == contextHandle) GL.currentContext = 0; GL.deleteContext(contextHandle); @@ -2484,6 +2456,10 @@ var ASM_CONSTS = { } + function _emscripten_webgl_make_context_current(contextHandle) { + var success = GL.makeContextCurrent(contextHandle); + return success ? 0 : -5; + } var SYSCALLS = {mappings:{},buffers:[null,[],[]],printChar:function(stream, curr) { var buffer = SYSCALLS.buffers[stream]; @@ -3074,9 +3050,6 @@ var asmLibraryArg = { "emscripten_resize_heap": _emscripten_resize_heap, "emscripten_set_canvas_element_size": _emscripten_set_canvas_element_size, "emscripten_set_click_callback_on_thread": _emscripten_set_click_callback_on_thread, - "emscripten_set_mousedown_callback_on_thread": _emscripten_set_mousedown_callback_on_thread, - "emscripten_set_mousemove_callback_on_thread": _emscripten_set_mousemove_callback_on_thread, - "emscripten_set_mouseup_callback_on_thread": _emscripten_set_mouseup_callback_on_thread, "emscripten_webgl_create_context": _emscripten_webgl_create_context, "emscripten_webgl_destroy_context": _emscripten_webgl_destroy_context, "emscripten_webgl_init_context_attributes": _emscripten_webgl_init_context_attributes, @@ -3133,15 +3106,6 @@ var ___errno_location = Module["___errno_location"] = createExportWrapper("__err /** @type {function(...*):?} */ var _fflush = Module["_fflush"] = createExportWrapper("fflush"); -/** @type {function(...*):?} */ -var stackSave = Module["stackSave"] = createExportWrapper("stackSave"); - -/** @type {function(...*):?} */ -var stackRestore = Module["stackRestore"] = createExportWrapper("stackRestore"); - -/** @type {function(...*):?} */ -var stackAlloc = Module["stackAlloc"] = createExportWrapper("stackAlloc"); - /** @type {function(...*):?} */ var _emscripten_stack_init = Module["_emscripten_stack_init"] = function() { return (_emscripten_stack_init = Module["_emscripten_stack_init"] = Module["asm"]["emscripten_stack_init"]).apply(null, arguments); @@ -3157,6 +3121,15 @@ var _emscripten_stack_get_end = Module["_emscripten_stack_get_end"] = function() return (_emscripten_stack_get_end = Module["_emscripten_stack_get_end"] = Module["asm"]["emscripten_stack_get_end"]).apply(null, arguments); }; +/** @type {function(...*):?} */ +var stackSave = Module["stackSave"] = createExportWrapper("stackSave"); + +/** @type {function(...*):?} */ +var stackRestore = Module["stackRestore"] = createExportWrapper("stackRestore"); + +/** @type {function(...*):?} */ +var stackAlloc = Module["stackAlloc"] = createExportWrapper("stackAlloc"); + /** @type {function(...*):?} */ var _malloc = Module["_malloc"] = createExportWrapper("malloc"); @@ -3242,7 +3215,10 @@ if (!Object.getOwnPropertyDescriptor(Module, "Protocols")) Module["Protocols"] = if (!Object.getOwnPropertyDescriptor(Module, "Sockets")) Module["Sockets"] = function() { abort("'Sockets' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }; if (!Object.getOwnPropertyDescriptor(Module, "getRandomDevice")) Module["getRandomDevice"] = function() { abort("'getRandomDevice' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }; if (!Object.getOwnPropertyDescriptor(Module, "traverseStack")) Module["traverseStack"] = function() { abort("'traverseStack' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "convertFrameToPC")) Module["convertFrameToPC"] = function() { abort("'convertFrameToPC' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }; if (!Object.getOwnPropertyDescriptor(Module, "UNWIND_CACHE")) Module["UNWIND_CACHE"] = function() { abort("'UNWIND_CACHE' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "saveInUnwindCache")) Module["saveInUnwindCache"] = function() { abort("'saveInUnwindCache' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "convertPCtoSourceLocation")) Module["convertPCtoSourceLocation"] = function() { abort("'convertPCtoSourceLocation' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }; if (!Object.getOwnPropertyDescriptor(Module, "readAsmConstArgsArray")) Module["readAsmConstArgsArray"] = function() { abort("'readAsmConstArgsArray' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }; if (!Object.getOwnPropertyDescriptor(Module, "readAsmConstArgs")) Module["readAsmConstArgs"] = function() { abort("'readAsmConstArgs' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }; if (!Object.getOwnPropertyDescriptor(Module, "mainThreadEM_ASM")) Module["mainThreadEM_ASM"] = function() { abort("'mainThreadEM_ASM' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }; -- cgit v1.2.1