diff --git a/armorforge/project.js b/armorforge/project.js index 27d3b703..ccc1a651 100644 --- a/armorforge/project.js +++ b/armorforge/project.js @@ -28,16 +28,9 @@ else if (flags.ios) { project.addAssets("Assets/readme/readme_ios.txt", { destination: "{name}" }); } -if (flags.plugin_embed) { - project.addAssets("Assets/plugins/embed/*", { destination: "data/plugins/{name}" }); -} -else { - project.addAssets("Assets/plugins/wasm/*", { destination: "data/plugins/{name}" }); -} - if (flags.physics) { project.addDefine("arm_physics"); - project.addAssets("Assets/plugins/wasm/ammo/*", { destination: "data/plugins/{name}" }); + project.addAssets("Assets/plugins/ammo/*", { destination: "data/plugins/{name}" }); } if (flags.raytrace) { diff --git a/armorlab/Assets/plugins/embed/import_svg.js b/armorlab/Assets/plugins/import_svg.js similarity index 100% rename from armorlab/Assets/plugins/embed/import_svg.js rename to armorlab/Assets/plugins/import_svg.js diff --git a/armorlab/Assets/plugins/wasm/import_svg.js b/armorlab/Assets/plugins/wasm/import_svg.js deleted file mode 100644 index f01e6842..00000000 --- a/armorlab/Assets/plugins/wasm/import_svg.js +++ /dev/null @@ -1,57 +0,0 @@ - -let Module = {}; -Module["instantiateWasm"] = function(imports, successCallback) { - let wasmbin = Krom.loadBlob("data/plugins/import_svg.wasm"); - let module = new WebAssembly.Module(wasmbin); - let inst = new WebAssembly.Instance(module, imports); - successCallback(inst); - return inst.exports; -}; -Module.print = console.log; -Module.printErr = console.log; - -// emscripten-generated glue -var a;a||(a=typeof Module !== 'undefined' ? Module : {});var g={},h;for(h in a)a.hasOwnProperty(h)&&(g[h]=a[h]);var k;k=function(b){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(b));b=read(b,"binary");"object"===typeof b||m("Assertion failed: undefined");return b};"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:print); -var n=a.print||console.log.bind(console),p=a.printErr||console.warn.bind(console);for(h in g)g.hasOwnProperty(h)&&(a[h]=g[h]);g=null;var q;a.wasmBinary&&(q=a.wasmBinary);var noExitRuntime;a.noExitRuntime&&(noExitRuntime=a.noExitRuntime);"object"!==typeof WebAssembly&&p("no native wasm support detected");var r,t=new WebAssembly.Table({initial:2,maximum:2,element:"anyfunc"}),u=!1,v,w,x; -function y(b){v=b;a.HEAP8=new Int8Array(b);a.HEAP16=new Int16Array(b);a.HEAP32=x=new Int32Array(b);a.HEAPU8=w=new Uint8Array(b);a.HEAPU16=new Uint16Array(b);a.HEAPU32=new Uint32Array(b);a.HEAPF32=new Float32Array(b);a.HEAPF64=new Float64Array(b)}var z=a.INITIAL_MEMORY||16777216;a.wasmMemory?r=a.wasmMemory:r=new WebAssembly.Memory({initial:z/65536,maximum:32768});r&&(v=r.buffer);z=v.byteLength;y(v);x[1492]=5249008; -function A(b){for(;0>>=0;var c=w.length;if(2147483648=d;d*=2){var f=c*(1+.2/d);f=Math.min(f,b+100663296);f=Math.max(16777216,b,f);0>>16);y(r.buffer);var e=1;break a}catch(l){}e=void 0}if(e)return!0}return!1},memory:r,table:t},P=function(){function b(e){a.asm=e.exports;G--;a.monitorRunDependencies&&a.monitorRunDependencies(G);0==G&&(null!==H&&(clearInterval(H), -H=null),I&&(e=I,I=null,e()))}function c(e){b(e.instance)}function d(e){return M().then(function(l){return WebAssembly.instantiate(l,f)}).then(e,function(l){p("failed to asynchronously prepare wasm: "+l);m(l)})}var f={a:O};G++;a.monitorRunDependencies&&a.monitorRunDependencies(G);if(a.instantiateWasm)try{return a.instantiateWasm(f,b)}catch(e){return p("Module.instantiateWasm callback failed with error: "+e),!1}(function(){if(q||"function"!==typeof WebAssembly.instantiateStreaming||J()||"function"!== -typeof fetch)return d(c);fetch(K,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,f).then(c,function(l){p("wasm streaming compile failed: "+l);p("falling back to ArrayBuffer instantiation");d(c)})})})();return{}}();a.asm=P;var N=a.___wasm_call_ctors=function(){return(N=a.___wasm_call_ctors=a.asm.c).apply(null,arguments)};a._init=function(){return(a._init=a.asm.d).apply(null,arguments)};a._parse=function(){return(a._parse=a.asm.e).apply(null,arguments)}; -a._get_pixels=function(){return(a._get_pixels=a.asm.f).apply(null,arguments)};a._get_pixels_w=function(){return(a._get_pixels_w=a.asm.g).apply(null,arguments)};a._get_pixels_h=function(){return(a._get_pixels_h=a.asm.h).apply(null,arguments)};a._destroy=function(){return(a._destroy=a.asm.i).apply(null,arguments)};a.asm=P;var Q;I=function R(){Q||S();Q||(I=R)}; -function S(){function b(){if(!Q&&(Q=!0,a.calledRun=!0,!u)){A(C);A(D);if(a.onRuntimeInitialized)a.onRuntimeInitialized();if(a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;){var c=a.postRun.shift();E.unshift(c)}A(E)}}if(!(0>>=0;var c=w.length;if(2147483648=d;d*=2){var f=c*(1+.2/d);f=Math.min(f,b+100663296);f=Math.max(16777216,b,f);0>>16);y(r.buffer);var e=1;break a}catch(l){}e=void 0}if(e)return!0}return!1},memory:r,table:t},P=function(){function b(e){a.asm=e.exports;G--;a.monitorRunDependencies&&a.monitorRunDependencies(G);0==G&&(null!==H&&(clearInterval(H), -H=null),I&&(e=I,I=null,e()))}function c(e){b(e.instance)}function d(e){return M().then(function(l){return WebAssembly.instantiate(l,f)}).then(e,function(l){p("failed to asynchronously prepare wasm: "+l);m(l)})}var f={a:O};G++;a.monitorRunDependencies&&a.monitorRunDependencies(G);if(a.instantiateWasm)try{return a.instantiateWasm(f,b)}catch(e){return p("Module.instantiateWasm callback failed with error: "+e),!1}(function(){if(q||"function"!==typeof WebAssembly.instantiateStreaming||J()||"function"!== -typeof fetch)return d(c);fetch(K,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,f).then(c,function(l){p("wasm streaming compile failed: "+l);p("falling back to ArrayBuffer instantiation");d(c)})})})();return{}}();a.asm=P;var N=a.___wasm_call_ctors=function(){return(N=a.___wasm_call_ctors=a.asm.c).apply(null,arguments)};a._init=function(){return(a._init=a.asm.d).apply(null,arguments)};a._parse=function(){return(a._parse=a.asm.e).apply(null,arguments)}; -a._get_pixels=function(){return(a._get_pixels=a.asm.f).apply(null,arguments)};a._get_pixels_w=function(){return(a._get_pixels_w=a.asm.g).apply(null,arguments)};a._get_pixels_h=function(){return(a._get_pixels_h=a.asm.h).apply(null,arguments)};a._destroy=function(){return(a._destroy=a.asm.i).apply(null,arguments)};a.asm=P;var Q;I=function R(){Q||S();Q||(I=R)}; -function S(){function b(){if(!Q&&(Q=!0,a.calledRun=!0,!u)){A(C);A(D);if(a.onRuntimeInitialized)a.onRuntimeInitialized();if(a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;){var c=a.postRun.shift();E.unshift(c)}A(E)}}if(!(0>10,56320|1023&i)))):r+=String.fromCharCode(i)}return r}function D(e){return e?B(E,e,void 0):""}function ia(e){F=e,g.HEAP8=G=new Int8Array(e),g.HEAP16=new Int16Array(e),g.HEAP32=H=new Int32Array(e),g.HEAPU8=E=new Uint8Array(e),g.HEAPU16=new Uint16Array(e),g.HEAPU32=new Uint32Array(e),g.HEAPF32=new Float32Array(e),g.HEAPF64=new Float64Array(e)}var A,ja=g.INITIAL_MEMORY||16777216;(A=g.wasmMemory?g.wasmMemory:new WebAssembly.Memory({initial:ja/65536,maximum:32768}))&&(F=A.buffer),ja=F.byteLength,ia(F);var ka=[],la=[],ma=[],na=[];function oa(){var e=g.preRun.shift();ka.unshift(e)}var pa=Math.abs,qa=Math.ceil,ra=Math.floor,sa=Math.min,I=0,ta=null,J=null;function z(e){throw g.onAbort&&g.onAbort(e),t(e),fa=!0,new WebAssembly.RuntimeError("abort("+e+"). Build with -s ASSERTIONS=1 for more info.")}function ua(){var e=K;return String.prototype.startsWith?e.startsWith("data:application/octet-stream;base64,"):0===e.indexOf("data:application/octet-stream;base64,")}g.preloadedImages={},g.preloadedAudios={};var va,L,xa,K="import_usdc.wasm";function wa(){try{if(x)return new Uint8Array(x);if(ba)return ba(K);throw"both async and sync fetching of the wasm failed"}catch(e){z(e)}}function M(e){for(;0>>0),0!=t&&(n=Math.max(n,256)),t=e.B,e.B=new Uint8Array(n),0n)e.B.length=n;else for(;e.B.length=e.node.F)return 0;if(8<(e=Math.min(e.node.F-a,r))&&o.subarray)n.set(o.subarray(a,a+e),t);else for(r=0;r>>0)%T.length}function R(e,n){var t;if(t=(t=W(e,"x"))?t:e.C.S?0:2)throw new P(t,e);for(t=T[Wa(e.id,n)];t;t=t.wa){var r=t.name;if(t.parent.id===e.id&&r===n)return t}return e.C.S(e,n)}function Na(e,n,t,r){return n=Wa((e=new Xa(e,n,t,r)).parent.id,e.name),e.wa=T[n],T[n]=e}var Ya={r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218};function Za(e){var n=["r","w","rw"][3&e];return 512&e&&(n+="w"),n}function W(e,n){return Ta||(-1===n.indexOf("r")||292&e.mode)&&(-1===n.indexOf("w")||146&e.mode)&&(-1===n.indexOf("x")||73&e.mode)?0:2}function $a(e,n){try{return R(e,n),20}catch(e){}return W(e,"wx")}function ab(){for(var e=0;e<=4096;e++)if(!S[e])return e;throw new P(33)}function bb(e){X||((X=function(){}).prototype={});var n,t=new X;for(n in e)t[n]=e[n];return e=t,t=ab(),e.O=t,S[t]=e}var lb,Ma={open:function(e){e.D=Ra[e.node.Y].D,e.D.open&&e.D.open(e)},N:function(){throw new P(70)}};function Ha(e,n){Ra[e]={D:n}}function cb(e,n){var t="/"===n,r=!n;if(t&&Qa)throw new P(10);if(!t&&!r){var a=V(n,{ka:!1});if(n=a.path,(a=a.node).X)throw new P(10);if(16384!=(61440&a.mode))throw new P(54)}n={type:e,Qa:{},na:n,va:[]},((e=e.L(n)).L=n).root=e,t?Qa=e:a&&(a.X=n,a.L&&a.L.va.push(n))}function eb(e,n,t){var r=V(e,{parent:!0}).node;if(!(e=Da(e))||"."===e||".."===e)throw new P(28);var a=$a(r,e);if(a)throw new P(a);if(!r.C.W)throw new P(63);return r.C.W(r,e,n,t)}function Y(e){eb(e,16895,0)}function fb(e,n,t){void 0===t&&(t=n,n=438),eb(e,8192|n,t)}function gb(e,n){if(!O(e))throw new P(44);var t=V(n,{parent:!0}).node;if(!t)throw new P(44);var r=$a(t,n=Da(n));if(r)throw new P(r);if(!t.C.Z)throw new P(63);t.C.Z(t,n,e)}function Ua(e){if(!(e=V(e).node))throw new P(44);if(!e.C.T)throw new P(28);return O(Va(e.parent),e.C.T(e))}function hb(n,e){if(""===n)throw new P(44);if("string"==typeof e){var r=Ya[e];if(void 0===r)throw Error("Unknown file open mode: "+e);e=r}var a=64&e?4095&(void 0===a?438:a)|32768:0;if("object"==typeof n)var o=n;else{n=N(n);try{o=V(n,{ja:!(131072&e)}).node}catch(e){}}if(r=!1,64&e)if(o){if(128&e)throw new P(20)}else o=eb(n,a,0),r=!0;if(!o)throw new P(44);if(8192==(61440&o.mode)&&(e&=-513),65536&e&&16384!=(61440&o.mode))throw new P(54);if(!r&&(a=o?40960==(61440&o.mode)?32:16384==(61440&o.mode)&&("r"!==Za(e)||512&e)?31:W(o,Za(e)):44))throw new P(a);if(512&e){var i="string"==typeof(a=o)?V(a,{ja:!0}).node:a;if(!i.C.K)throw new P(63);if(16384==(61440&i.mode))throw new P(31);if(32768!=(61440&i.mode))throw new P(28);if(a=W(i,"w"))throw new P(a);i.C.K(i,{size:0,timestamp:Date.now()})}e&=-131713,(o=bb({node:o,path:Va(o),flags:e,seekable:!0,position:0,D:o.D,Ea:[],error:!1})).D.open&&o.D.open(o),!g.logReadFiles||1&e||(n in(ib=ib||{})||(ib[n]=1,t("FS.trackingDelegate error on read file: "+n)));try{U.onOpenFile&&(o=0,1!=(2097155&e)&&(o|=1),0!=(2097155&e)&&(o|=2),U.onOpenFile(n,o))}catch(e){t("FS.trackingDelegate['onOpenFile']('"+n+"', flags) threw an exception: "+e.message)}}function jb(e,n,t){if(null===e.O)throw new P(8);if(!e.seekable||!e.D.N)throw new P(70);if(0!=t&&1!=t&&2!=t)throw new P(28);e.position=e.D.N(e,n,t),e.Ea=[]}function kb(){P||((P=function(e,n){this.node=n,this.za=function(e){this.V=e},this.za(e),this.message="FS error"}).prototype=Error(),P.prototype.constructor=P,[44].forEach(function(e){Oa[e]=new P(e),Oa[e].stack=""}))}function mb(e,n){var t=0;return e&&(t|=365),n&&(t|=146),t}function Z(e,u,o){e=N("/dev/"+e);var n=mb(!!u,!!o);nb=nb||64;var t=nb++<<8|0;Ha(t,{open:function(e){e.seekable=!1},close:function(){o&&o.buffer&&o.buffer.length&&o(10)},read:function(e,n,t,r){for(var a=0,o=0;or-e.getDate())){e.setDate(e.getDate()+n);break}n-=r-e.getDate()+1,e.setDate(1),t<11?e.setMonth(t+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return e}function vb(e,n,t,r){function a(e,n,t){for(e="number"==typeof e?e.toString():e||"";e.length>2];for(var f in r={Ca:H[r>>2],Ba:H[r+4>>2],$:H[r+8>>2],U:H[r+12>>2],R:H[r+16>>2],H:H[r+20>>2],aa:H[r+24>>2],ba:H[r+28>>2],Sa:H[r+32>>2],Aa:H[r+36>>2],Da:c?D(c):""},t=D(t),c={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})t=t.replace(new RegExp(f,"g"),c[f]);var l="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),g="January February March April May June July August September October November December".split(" "),c={"%a":function(e){return l[e.aa].substring(0,3)},"%A":function(e){return l[e.aa]},"%b":function(e){return g[e.R].substring(0,3)},"%B":function(e){return g[e.R]},"%C":function(e){return o((e.H+1900)/100|0,2)},"%d":function(e){return o(e.U,2)},"%e":function(e){return a(e.U,2," ")},"%g":function(e){return s(e).toString().substring(2)},"%G":s,"%H":function(e){return o(e.$,2)},"%I":function(e){return 0==(e=e.$)?e=12:12n?0:(G.set(f,e),f.length-1)}function Xa(e,n,t,r){e=e||this,this.parent=e,this.L=e.L,this.X=null,this.id=Sa++,this.name=n,this.mode=t,this.C={},this.D={},this.Y=r}function Ja(e,n){for(var t=0,r=0;r>6}else{if(u<=65535){if(o<=r+2)break;t[r++]=224|u>>12}else{if(o<=r+3)break;t[r++]=240|u>>18,t[r++]=128|u>>12&63}t[r++]=128|u>>6&63}t[r++]=128|63&u}}t[r]=0,e=r-a}else e=0;return n&&(t.length=e),t}Object.defineProperties(Xa.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}}}),kb(),T=Array(4096),cb(Q,"/"),Y("/tmp"),Y("/home"),Y("/home/web_user"),function(){Y("/dev"),Ha(259,{read:function(){return 0},write:function(e,n,t,r){return r}}),fb("/dev/null",259),Ga(1280,Ka),Ga(1536,La),fb("/dev/tty",1280),fb("/dev/tty1",1536);var e=Ea();Z("random",e),Z("urandom",e),Y("/dev/shm"),Y("/dev/shm/tmp")}(),Y("/proc"),Y("/proc/self"),Y("/proc/self/fd"),cb({L:function(){var e=Na("/proc/self","fd",16895,73);return e.C={S:function(e,n){var t=S[+n];if(!t)throw new P(8);return(e={parent:null,L:{na:"fake"},C:{T:function(){return t.path}}}).parent=e}},e}},"/proc/self/fd"),la.push({ua:function(){wb()}});var yb={b:function(e,n,t,r){z("Assertion failed: "+D(e)+", at: "+[n?D(n):"unknown filename",t,r?D(r):"unknown function"])},c:function(){z()},m:function(e,n,t){E.copyWithin(e,n,n+t)},d:function(e){e>>>=0;var n=E.length;if(2147483648>>16),ia(A.buffer);var a=1;break e}catch(e){}a=void 0}if(a)return!0}return!1},h:function(r,a){var o=0;return za().forEach(function(e,n){var t=a+o;for(n=H[r+4*n>>2]=t,t=0;t>0]=e.charCodeAt(t);G[n>>0]=0,o+=e.length+1}),0},i:function(e,n){var t=za();H[e>>2]=t.length;var r=0;return t.forEach(function(e){r+=e.length+1}),H[n>>2]=r,0},k:function(e){try{var n=pb(e);if(null===n.O)throw new P(8);n.da&&(n.da=null);try{n.D.close&&n.D.close(n)}catch(e){throw e}finally{S[n.O]=null}return n.O=null,0}catch(e){return void 0!==ob&&e instanceof P||z(e),e.V}},j:function(e,n,t,r){try{e:{for(var a=pb(e),o=e=0;o>2],u=a,s=H[n+8*o>>2],c=i,f=void 0,l=G;if(c<0||f<0)throw new P(28);if(null===u.O)throw new P(8);if(1==(2097155&u.flags))throw new P(8);if(16384==(61440&u.node.mode))throw new P(31);if(!u.D.read)throw new P(28);var g=void 0!==f;if(g){if(!u.seekable)throw new P(70)}else f=u.position;var d=u.D.read(u,l,s,c,f);g||(u.position+=d);var h=d;if(h<0){var w=-1;break e}if(e+=h,h>2]=w,0}catch(e){return void 0!==ob&&e instanceof P||z(e),e.V}},l:function(e,n,t,r,a){try{var o=pb(e);return(e=4294967296*t+(n>>>0))<=-9007199254740992||9007199254740992<=e?-61:(jb(o,e,r),xa=[o.position>>>0,(L=o.position,1<=+pa(L)?0>>0:~~+qa((L-(~~L>>>0))/4294967296)>>>0:0)],H[a>>2]=xa[0],H[a+4>>2]=xa[1],o.da&&0===e&&0===r&&(o.da=null),0)}catch(e){return void 0!==ob&&e instanceof P||z(e),e.V}},e:function(e,n,r,a){try{e:{for(var o=pb(e),i=e=0;i>2],c=H[n+(8*i+4)>>2],f=void 0,l=G;if(c<0||f<0)throw new P(28);if(null===u.O)throw new P(8);if(0==(2097155&u.flags))throw new P(8);if(16384==(61440&u.node.mode))throw new P(31);if(!u.D.write)throw new P(28);u.seekable&&1024&u.flags&&jb(u,0,2);var g=void 0!==f;if(g){if(!u.seekable)throw new P(70)}else f=u.position;var d=u.D.write(u,l,s,c,f,void 0);g||(u.position+=d);try{u.path&&U.onWriteToFile&&U.onWriteToFile(u.path)}catch(e){t("FS.trackingDelegate['onWriteToFile']('"+u.path+"') threw an exception: "+e.message)}var h=d;if(h<0){var w=-1;break e}e+=h}w=e}return H[a>>2]=w,0}catch(e){return void 0!==ob&&e instanceof P||z(e),e.V}},a:A,g:function(e,n,t,r){return vb(e,n,t,r)},f:function(e){switch(e){case 30:return 16384;case 85:return 131072;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:case 79:return 200809;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:return"object"==typeof navigator&&navigator.hardwareConcurrency||1}return H[xb()>>2]=28,-1}};!function(){function n(e){g.asm=e.exports,ea=g.asm.n,I--,g.monitorRunDependencies&&g.monitorRunDependencies(I),0==I&&(null!==ta&&(clearInterval(ta),ta=null),J&&(e=J,J=null,e()))}function r(e){n(e.instance)}function a(e){return Promise.resolve().then(wa).then(function(e){return WebAssembly.instantiate(e,o)}).then(e,function(e){t("failed to asynchronously prepare wasm: "+e),z(e)})}var o={a:yb};if(I++,g.monitorRunDependencies&&g.monitorRunDependencies(I),g.instantiateWasm)try{return g.instantiateWasm(o,n)}catch(e){return t("Module.instantiateWasm callback failed with error: "+e)}x||"function"!=typeof WebAssembly.instantiateStreaming||ua()||"function"!=typeof fetch?a(r):fetch(K,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,o).then(r,function(e){return t("wasm streaming compile failed: "+e),t("falling back to ArrayBuffer instantiation"),a(r)})})}();var wb=g.___wasm_call_ctors=function(){return(wb=g.___wasm_call_ctors=g.asm.o).apply(null,arguments)};g.__Z4initi=function(){return(g.__Z4initi=g.asm.p).apply(null,arguments)};var Pa=g._malloc=function(){return(Pa=g._malloc=g.asm.q).apply(null,arguments)};g.__Z5parsev=function(){return(g.__Z5parsev=g.asm.r).apply(null,arguments)},g.__Z7destroyv=function(){return(g.__Z7destroyv=g.asm.s).apply(null,arguments)},g.__Z15get_index_countv=function(){return(g.__Z15get_index_countv=g.asm.t).apply(null,arguments)},g.__Z16get_vertex_countv=function(){return(g.__Z16get_vertex_countv=g.asm.u).apply(null,arguments)},g.__Z13get_scale_posv=function(){return(g.__Z13get_scale_posv=g.asm.v).apply(null,arguments)},g.__Z11get_indicesv=function(){return(g.__Z11get_indicesv=g.asm.w).apply(null,arguments)},g.__Z13get_positionsv=function(){return(g.__Z13get_positionsv=g.asm.x).apply(null,arguments)},g.__Z11get_normalsv=function(){return(g.__Z11get_normalsv=g.asm.y).apply(null,arguments)},g.__Z7get_uvsv=function(){return(g.__Z7get_uvsv=g.asm.z).apply(null,arguments)};var zb,xb=g.___errno_location=function(){return(xb=g.___errno_location=g.asm.A).apply(null,arguments)};function Bb(){function e(){if(!zb&&(zb=!0,g.calledRun=!0,!fa)){if(g.noFSInit||lb||(lb=!0,kb(),g.stdin,g.stdout,g.stderr,g.stdin?Z("stdin",g.stdin):gb("/dev/tty","/dev/stdin"),g.stdout?Z("stdout",null,g.stdout):gb("/dev/tty","/dev/stdout"),g.stderr?Z("stderr",null,g.stderr):gb("/dev/tty1","/dev/stderr"),hb("/dev/stdin","r"),hb("/dev/stdout","w"),hb("/dev/stderr","w")),M(la),Ta=!1,M(ma),g.onRuntimeInitialized&&g.onRuntimeInitialized(),g.postRun)for("function"==typeof g.postRun&&(g.postRun=[g.postRun]);g.postRun.length;){var e=g.postRun.shift();na.unshift(e)}M(na)}}if(!(0=f);)++e;if(16d?f+=String.fromCharCode(d):(d-=65536,f+=String.fromCharCode(55296|d>>10,56320|d&1023))}}else f+=String.fromCharCode(d)}return f}function x(b){return b?w(y,b,void 0):""}var z,y,A; -function B(){var b=r.buffer;z=b;a.HEAP8=new Int8Array(b);a.HEAP16=new Int16Array(b);a.HEAP32=A=new Int32Array(b);a.HEAPU8=y=new Uint8Array(b);a.HEAPU16=new Uint16Array(b);a.HEAPU32=new Uint32Array(b);a.HEAPF32=new Float32Array(b);a.HEAPF64=new Float64Array(b)}var C,G=[],H=[],I=[],J=[];H.push({v:function(){K()}});function L(){var b=a.preRun.shift();G.unshift(b)}var M=0,N=null,O=null;a.preloadedImages={};a.preloadedAudios={}; -function m(b){if(a.onAbort)a.onAbort(b);p(b);t=!0;throw new WebAssembly.RuntimeError("abort("+b+"). Build with -s ASSERTIONS=1 for more info.");}function P(){var b=Q;return String.prototype.startsWith?b.startsWith("data:application/octet-stream;base64,"):0===b.indexOf("data:application/octet-stream;base64,")}var Q="xatlas.wasm";if(!P()){var R=Q;Q=a.locateFile?a.locateFile(R,""):""+R} -function T(){return Promise.resolve().then(function(){a:{var b=Q;try{if(b==Q&&q){var c=new Uint8Array(q);break a}if(l){c=l(b);break a}throw"both async and sync fetching of the wasm failed";}catch(e){m(e)}c=void 0}return c})}function U(b){for(;0>>=0;var c=y.length;if(2147483648=e;e*=2){var f=c*(1+.2/e);f=Math.min(f,b+100663296);f=Math.max(16777216,b,f);0>>16);B();var d=1;break a}catch(g){}d=void 0}if(d)return!0}return!1},c:function(b,c,e, -f){for(var d=0,g=0;g>2],S=A[c+(8*g+4)>>2],D=0;D>2]=d;return 0}}; -(function(){function b(d){a.asm=d.exports;r=a.asm.e;B();C=a.asm.f;M--;a.monitorRunDependencies&&a.monitorRunDependencies(M);0==M&&(null!==N&&(clearInterval(N),N=null),O&&(d=O,O=null,d()))}function c(d){b(d.instance)}function e(d){return T().then(function(g){return WebAssembly.instantiate(g,f)}).then(d,function(g){p("failed to asynchronously prepare wasm: "+g);m(g)})}var f={a:W};M++;a.monitorRunDependencies&&a.monitorRunDependencies(M);if(a.instantiateWasm)try{return a.instantiateWasm(f,b)}catch(d){return p("Module.instantiateWasm callback failed with error: "+ -d),!1}(function(){return q||"function"!==typeof WebAssembly.instantiateStreaming||P()||"function"!==typeof fetch?e(c):fetch(Q,{credentials:"same-origin"}).then(function(d){return WebAssembly.instantiateStreaming(d,f).then(c,function(g){p("wasm streaming compile failed: "+g);p("falling back to ArrayBuffer instantiation");return e(c)})})})();return{}})();var K=a.___wasm_call_ctors=function(){return(K=a.___wasm_call_ctors=a.asm.g).apply(null,arguments)}; -a._setVertexCount=function(){return(a._setVertexCount=a.asm.h).apply(null,arguments)};a._setIndexCount=function(){return(a._setIndexCount=a.asm.i).apply(null,arguments)};a._setPositions=function(){return(a._setPositions=a.asm.j).apply(null,arguments)};a._setNormals=function(){return(a._setNormals=a.asm.k).apply(null,arguments)};a._setIndices=function(){return(a._setIndices=a.asm.l).apply(null,arguments)};a._getVertexCount=function(){return(a._getVertexCount=a.asm.m).apply(null,arguments)}; -a._getIndexCount=function(){return(a._getIndexCount=a.asm.n).apply(null,arguments)};a._getPositions=function(){return(a._getPositions=a.asm.o).apply(null,arguments)};a._getNormals=function(){return(a._getNormals=a.asm.p).apply(null,arguments)};a._getUVs=function(){return(a._getUVs=a.asm.q).apply(null,arguments)};a._getIndices=function(){return(a._getIndices=a.asm.r).apply(null,arguments)};a._unwrap=function(){return(a._unwrap=a.asm.s).apply(null,arguments)}; -a._destroy=function(){return(a._destroy=a.asm.t).apply(null,arguments)};var X;O=function Y(){X||Z();X||(O=Y)}; -function Z(){function b(){if(!X&&(X=!0,a.calledRun=!0,!t)){U(H);U(I);if(a.onRuntimeInitialized)a.onRuntimeInitialized();if(a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;){var c=a.postRun.shift();J.unshift(c)}U(J)}}if(!(0 -#endif using namespace tinyddsloader; static void *buf; /* Pointer to dds file data */ @@ -15,13 +10,13 @@ static uint32_t w; static uint32_t h; static uint32_t format; -EMSCRIPTEN_KEEPALIVE uint8_t *io_dds_init(int bufSize) { +uint8_t *io_dds_init(int bufSize) { size = bufSize; buf = (uint8_t *)malloc(sizeof(uint8_t) * bufSize); return (uint8_t *)buf; } -EMSCRIPTEN_KEEPALIVE void io_dds_parse() { +void io_dds_parse() { if (pixels != NULL) { free(pixels); } @@ -44,12 +39,12 @@ EMSCRIPTEN_KEEPALIVE void io_dds_parse() { pixels = (uint8_t *)dds.GetImageData(0, 0)->m_mem; } -EMSCRIPTEN_KEEPALIVE void io_dds_destroy() { +void io_dds_destroy() { free(buf); free(pixels); } -EMSCRIPTEN_KEEPALIVE uint8_t *io_dds_get_pixels() { return pixels; } -EMSCRIPTEN_KEEPALIVE uint32_t io_dds_get_pixels_w() { return w; } -EMSCRIPTEN_KEEPALIVE uint32_t io_dds_get_pixels_h() { return h; } -EMSCRIPTEN_KEEPALIVE uint32_t io_dds_get_pixels_format() { return format; } +uint8_t *io_dds_get_pixels() { return pixels; } +uint32_t io_dds_get_pixels_w() { return w; } +uint32_t io_dds_get_pixels_h() { return h; } +uint32_t io_dds_get_pixels_format() { return format; } diff --git a/armorpaint/Plugins/Sources/io_fbx/io_fbx.c b/armorpaint/Plugins/Sources/io_fbx/io_fbx.c index ac50fb67..3024111e 100644 --- a/armorpaint/Plugins/Sources/io_fbx/io_fbx.c +++ b/armorpaint/Plugins/Sources/io_fbx/io_fbx.c @@ -2,12 +2,6 @@ #include #include -#ifdef WITH_PLUGIN_EMBED -#define EMSCRIPTEN_KEEPALIVE -#else -#include -#endif - static uint8_t *buffer = NULL; static uint32_t bufferLength = 0; static int bufOff; /* Pointer to fbx file data */ @@ -26,19 +20,17 @@ static float transform[16]; static bool has_next = false; static int current_node; -EMSCRIPTEN_KEEPALIVE uint8_t *io_fbx_getBuffer() { return buffer; } -EMSCRIPTEN_KEEPALIVE uint32_t io_fbx_getBufferLength() { return bufferLength; } +uint8_t *io_fbx_getBuffer() { return buffer; } +uint32_t io_fbx_getBufferLength() { return bufferLength; } static int allocate(int size) { - #ifdef WITH_PLUGIN_EMBED size += size % 4; // Byte align - #endif bufferLength += size; buffer = buffer == NULL ? (uint8_t *)malloc(bufferLength) : (uint8_t *)realloc(buffer, bufferLength); return bufferLength - size; } -EMSCRIPTEN_KEEPALIVE int io_fbx_init(int bufSize) { +int io_fbx_init(int bufSize) { if (!has_next) { current_node = 0; scale_pos = 0; @@ -166,7 +158,7 @@ void io_fbx_parse_mesh(ufbx_mesh *mesh) { else colaOff = 0; } -EMSCRIPTEN_KEEPALIVE void io_fbx_parse() { +void io_fbx_parse() { void *buf = &buffer[bufOff]; ufbx_load_opts opts = { .generate_missing_normals = true }; ufbx_scene *scene = ufbx_load_memory(buf, size, &opts, NULL); @@ -218,19 +210,19 @@ EMSCRIPTEN_KEEPALIVE void io_fbx_parse() { } } -EMSCRIPTEN_KEEPALIVE void io_fbx_destroy() { +void io_fbx_destroy() { free(buffer); buffer = NULL; } -EMSCRIPTEN_KEEPALIVE int io_fbx_get_index_count() { return index_count; } -EMSCRIPTEN_KEEPALIVE int io_fbx_get_vertex_count() { return vertex_count; } -EMSCRIPTEN_KEEPALIVE float io_fbx_get_scale_pos() { return scale_pos; } -EMSCRIPTEN_KEEPALIVE int io_fbx_get_indices() { return indaOff; } -EMSCRIPTEN_KEEPALIVE int io_fbx_get_positions() { return posaOff; } -EMSCRIPTEN_KEEPALIVE int io_fbx_get_normals() { return noraOff; } -EMSCRIPTEN_KEEPALIVE int io_fbx_get_uvs() { return texaOff; } -EMSCRIPTEN_KEEPALIVE int io_fbx_get_colors() { return colaOff; } -EMSCRIPTEN_KEEPALIVE char *io_fbx_get_name() { return &name[0]; } -EMSCRIPTEN_KEEPALIVE float *io_fbx_get_transform() { return &transform[0]; } -EMSCRIPTEN_KEEPALIVE int io_fbx_has_next() { return has_next; } +int io_fbx_get_index_count() { return index_count; } +int io_fbx_get_vertex_count() { return vertex_count; } +float io_fbx_get_scale_pos() { return scale_pos; } +int io_fbx_get_indices() { return indaOff; } +int io_fbx_get_positions() { return posaOff; } +int io_fbx_get_normals() { return noraOff; } +int io_fbx_get_uvs() { return texaOff; } +int io_fbx_get_colors() { return colaOff; } +char *io_fbx_get_name() { return &name[0]; } +float *io_fbx_get_transform() { return &transform[0]; } +int io_fbx_has_next() { return has_next; } diff --git a/armorpaint/Plugins/Sources/io_gltf/build.sh b/armorpaint/Plugins/Sources/io_gltf/build.sh deleted file mode 100644 index b4b0478f..00000000 --- a/armorpaint/Plugins/Sources/io_gltf/build.sh +++ /dev/null @@ -1 +0,0 @@ -emcc cgltf.c -o import_gltf.js -O3 --closure 1 -s ENVIRONMENT='shell' -s WASM_OBJECT_FILES=0 --llvm-lto 1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ALLOW_MEMORY_GROWTH=1 -fno-rtti -fno-exceptions diff --git a/armorpaint/Plugins/Sources/io_gltf/cgltf.c b/armorpaint/Plugins/Sources/io_gltf/cgltf.c index f198cccd..b74b4897 100644 --- a/armorpaint/Plugins/Sources/io_gltf/cgltf.c +++ b/armorpaint/Plugins/Sources/io_gltf/cgltf.c @@ -2,11 +2,6 @@ #define CGLTF_IMPLEMENTATION #include "cgltf.h" -#ifdef WITH_PLUGIN_EMBED -#define EMSCRIPTEN_KEEPALIVE -#else -#include -#endif #include static uint8_t *buffer = NULL; @@ -24,13 +19,11 @@ static int noraOff = 0; static int texaOff = 0; static float scale_pos; -EMSCRIPTEN_KEEPALIVE uint8_t *io_gltf_getBuffer() { return buffer; } -EMSCRIPTEN_KEEPALIVE uint32_t io_gltf_getBufferLength() { return bufferLength; } +uint8_t *io_gltf_getBuffer() { return buffer; } +uint32_t io_gltf_getBufferLength() { return bufferLength; } static int allocate(int size) { - #ifdef WITH_PLUGIN_EMBED size += size % 4; // Byte align - #endif bufferLength += size; buffer = buffer == NULL ? (uint8_t *)malloc(bufferLength) : (uint8_t *)realloc(buffer, bufferLength); return bufferLength - size; @@ -40,7 +33,7 @@ int io_gltf_read_u8_array(cgltf_accessor *a) { cgltf_buffer_view *v = a->buffer_view; unsigned char *ar = (unsigned char *)v->buffer->data + v->offset; int resOff = allocate(sizeof(unsigned int) * v->size); - unsigned int *res = &buffer[resOff]; + unsigned int *res = (unsigned int *)&buffer[resOff]; for (int i = 0; i < v->size; ++i) { res[i] = ar[i]; } @@ -51,7 +44,7 @@ int io_gltf_read_u16_array(cgltf_accessor *a) { cgltf_buffer_view *v = a->buffer_view; unsigned short *ar = (unsigned short *)v->buffer->data + v->offset / 2; int resOff = allocate(sizeof(unsigned int) * v->size / 2); - unsigned int *res = &buffer[resOff]; + unsigned int *res = (unsigned int *)&buffer[resOff]; for (int i = 0; i < v->size / 2; ++i) { res[i] = ar[i]; } @@ -62,7 +55,7 @@ int io_gltf_read_u32_array(cgltf_accessor *a) { cgltf_buffer_view *v = a->buffer_view; unsigned int *ar = (unsigned int *)v->buffer->data + v->offset / 4; int resOff = allocate(sizeof(unsigned int) * v->size / 4); - unsigned int *res = &buffer[resOff]; + unsigned int *res = (unsigned int *)&buffer[resOff]; for (int i = 0; i < v->size / 4; ++i) { res[i] = ar[i]; } @@ -79,15 +72,15 @@ float *io_gltf_read_f32_array_malloc(cgltf_accessor *a) { return res; } -EMSCRIPTEN_KEEPALIVE int io_gltf_init(int bufSize) { +int io_gltf_init(int bufSize) { size = bufSize; bufOff = allocate(sizeof(char) * bufSize); return bufOff; } -EMSCRIPTEN_KEEPALIVE void io_gltf_parse() { +void io_gltf_parse() { cgltf_options options = {0}; - char *buf = &buffer[bufOff]; + char *buf = (char *)&buffer[bufOff]; cgltf_result result = cgltf_parse(&options, buf, size, &data); if (result != cgltf_result_success) { return; } cgltf_load_buffers(&options, data, NULL); @@ -137,7 +130,7 @@ EMSCRIPTEN_KEEPALIVE void io_gltf_parse() { // Pack into 16bit posaOff = allocate(sizeof(short) * vertex_count * 4); - short *posa = &buffer[posaOff]; + short *posa = (short *)&buffer[posaOff]; for (int i = 0; i < vertex_count; ++i) { posa[i * 4 ] = posa32[i * 3 ] * 32767 * inv; posa[i * 4 + 1] = posa32[i * 3 + 1] * 32767 * inv; @@ -145,7 +138,7 @@ EMSCRIPTEN_KEEPALIVE void io_gltf_parse() { } noraOff = allocate(sizeof(short) * vertex_count * 2); - short *nora = &buffer[noraOff]; + short *nora = (short *)&buffer[noraOff]; if (nora32 != NULL) { for (int i = 0; i < vertex_count; ++i) { nora[i * 2 ] = nora32[i * 3 ] * 32767; @@ -156,7 +149,7 @@ EMSCRIPTEN_KEEPALIVE void io_gltf_parse() { } else { // Calc normals - int *inda = &buffer[indaOff]; + int *inda = (int *)&buffer[indaOff]; for (int i = 0; i < index_count / 3; ++i) { int i1 = inda[i * 3 ]; int i2 = inda[i * 3 + 1]; @@ -193,7 +186,7 @@ EMSCRIPTEN_KEEPALIVE void io_gltf_parse() { if (texa32 != NULL) { texaOff = allocate(sizeof(short) * vertex_count * 2); - short *texa = &buffer[texaOff]; + short *texa = (short *)&buffer[texaOff]; for (int i = 0; i < vertex_count; ++i) { texa[i * 2 ] = texa32[i * 2 ] * 32767; texa[i * 2 + 1] = texa32[i * 2 + 1] * 32767; @@ -202,16 +195,16 @@ EMSCRIPTEN_KEEPALIVE void io_gltf_parse() { } } -EMSCRIPTEN_KEEPALIVE void io_gltf_destroy() { +void io_gltf_destroy() { cgltf_free(data); free(buffer); buffer = NULL; } -EMSCRIPTEN_KEEPALIVE int io_gltf_get_index_count() { return index_count; } -EMSCRIPTEN_KEEPALIVE int io_gltf_get_vertex_count() { return vertex_count; } -EMSCRIPTEN_KEEPALIVE float io_gltf_get_scale_pos() { return scale_pos; } -EMSCRIPTEN_KEEPALIVE int io_gltf_get_indices() { return indaOff; } -EMSCRIPTEN_KEEPALIVE int io_gltf_get_positions() { return posaOff; } -EMSCRIPTEN_KEEPALIVE int io_gltf_get_normals() { return noraOff; } -EMSCRIPTEN_KEEPALIVE int io_gltf_get_uvs() { return texaOff; } +int io_gltf_get_index_count() { return index_count; } +int io_gltf_get_vertex_count() { return vertex_count; } +float io_gltf_get_scale_pos() { return scale_pos; } +int io_gltf_get_indices() { return indaOff; } +int io_gltf_get_positions() { return posaOff; } +int io_gltf_get_normals() { return noraOff; } +int io_gltf_get_uvs() { return texaOff; } diff --git a/armorpaint/Plugins/Sources/io_svg/build.sh b/armorpaint/Plugins/Sources/io_svg/build.sh deleted file mode 100644 index 0cedcc15..00000000 --- a/armorpaint/Plugins/Sources/io_svg/build.sh +++ /dev/null @@ -1 +0,0 @@ -emcc nanosvg.c -o import_svg.js -O3 --closure 1 -s ENVIRONMENT='shell' -s WASM_OBJECT_FILES=0 --llvm-lto 1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ALLOW_MEMORY_GROWTH=1 -fno-rtti -fno-exceptions diff --git a/armorpaint/Plugins/Sources/io_svg/nanosvg.c b/armorpaint/Plugins/Sources/io_svg/nanosvg.c index bdc2f42d..5d43df80 100644 --- a/armorpaint/Plugins/Sources/io_svg/nanosvg.c +++ b/armorpaint/Plugins/Sources/io_svg/nanosvg.c @@ -9,11 +9,6 @@ #include "nanosvg.h" #define NANOSVGRAST_IMPLEMENTATION #include "nanosvgrast.h" -#ifdef WITH_PLUGIN_EMBED -#define EMSCRIPTEN_KEEPALIVE -#else -#include -#endif static uint8_t *buffer = NULL; static uint32_t bufferLength = 0; @@ -22,25 +17,23 @@ static int pixelsOff; /* Rasterized pixel output */ static int w; static int h; -EMSCRIPTEN_KEEPALIVE uint8_t *io_svg_getBuffer() { return buffer; } -EMSCRIPTEN_KEEPALIVE uint32_t io_svg_getBufferLength() { return bufferLength; } +uint8_t *io_svg_getBuffer() { return buffer; } +uint32_t io_svg_getBufferLength() { return bufferLength; } static int allocate(int size) { - #ifdef WITH_PLUGIN_EMBED size += size % 4; // Byte align - #endif bufferLength += size; buffer = buffer == NULL ? (uint8_t *)malloc(bufferLength) : (uint8_t *)realloc(buffer, bufferLength); return bufferLength - size; } -EMSCRIPTEN_KEEPALIVE int io_svg_init(int buf_size) { +int io_svg_init(int buf_size) { bufOff = allocate(sizeof(char) * buf_size); return bufOff; } -EMSCRIPTEN_KEEPALIVE void io_svg_parse() { - char *buf = &buffer[bufOff]; +void io_svg_parse() { + char *buf = (char *)&buffer[bufOff]; NSVGimage *image = nsvgParse(buf, "px", 96.0f); w = (int)image->width; h = (int)image->height; @@ -53,11 +46,11 @@ EMSCRIPTEN_KEEPALIVE void io_svg_parse() { nsvgDeleteRasterizer(rast); } -EMSCRIPTEN_KEEPALIVE int io_svg_get_pixels() { return pixelsOff; } -EMSCRIPTEN_KEEPALIVE int io_svg_get_pixels_w() { return w; } -EMSCRIPTEN_KEEPALIVE int io_svg_get_pixels_h() { return h; } +int io_svg_get_pixels() { return pixelsOff; } +int io_svg_get_pixels_w() { return w; } +int io_svg_get_pixels_h() { return h; } -EMSCRIPTEN_KEEPALIVE void io_svg_destroy() { +void io_svg_destroy() { free(buffer); buffer = NULL; } diff --git a/armorpaint/Plugins/Sources/io_usd/build.sh b/armorpaint/Plugins/Sources/io_usd/build.sh deleted file mode 100644 index 15c1183e..00000000 --- a/armorpaint/Plugins/Sources/io_usd/build.sh +++ /dev/null @@ -1 +0,0 @@ -emcc io_usd.cc tinyusdz/tinyusdz.cc tinyusdz/integerCoding.cpp tinyusdz/lz4-compression.cc tinyusdz/pxrLZ4/lz4.cpp -o import_usd.js -O3 --closure 1 -DLZ4_DISABLE_DEPRECATE_WARNINGS -s ENVIRONMENT='shell' -s WASM_OBJECT_FILES=0 --llvm-lto 1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ALLOW_MEMORY_GROWTH=1 -fno-rtti -fno-exceptions \ No newline at end of file diff --git a/armorpaint/Plugins/Sources/io_usd/io_usd.cc b/armorpaint/Plugins/Sources/io_usd/io_usd.cc index e113fff6..3b688c40 100644 --- a/armorpaint/Plugins/Sources/io_usd/io_usd.cc +++ b/armorpaint/Plugins/Sources/io_usd/io_usd.cc @@ -1,10 +1,5 @@ #include "tinyusdz/tinyusdz.hh" #include -#ifdef WITH_PLUGIN_EMBED -#define EMSCRIPTEN_KEEPALIVE -#else -#include -#endif static uint8_t *buffer = NULL; static uint32_t bufferLength = 0; @@ -19,25 +14,23 @@ static int noraOff; static int texaOff; static float scale_pos; -extern "C" EMSCRIPTEN_KEEPALIVE uint8_t *io_usd_getBuffer() { return buffer; } -extern "C" EMSCRIPTEN_KEEPALIVE uint32_t io_usd_getBufferLength() { return bufferLength; } +extern "C" uint8_t *io_usd_getBuffer() { return buffer; } +extern "C" uint32_t io_usd_getBufferLength() { return bufferLength; } static int allocate(int size) { - #ifdef WITH_PLUGIN_EMBED size += size % 4; // Byte align - #endif bufferLength += size; buffer = buffer == NULL ? (uint8_t *)malloc(bufferLength) : (uint8_t *)realloc(buffer, bufferLength); return bufferLength - size; } -extern "C" EMSCRIPTEN_KEEPALIVE int io_usd_init(int bufSize) { +extern "C" int io_usd_init(int bufSize) { size = bufSize; bufOff = allocate(sizeof(uint8_t) * bufSize); return bufOff; } -extern "C" EMSCRIPTEN_KEEPALIVE void io_usd_parse() { +extern "C" void io_usd_parse() { tinyusdz::Scene scene; std::string warn; std::string err; @@ -160,15 +153,15 @@ extern "C" EMSCRIPTEN_KEEPALIVE void io_usd_parse() { } } -extern "C" EMSCRIPTEN_KEEPALIVE void io_usd_destroy() { +extern "C" void io_usd_destroy() { free(buffer); buffer = NULL; } -extern "C" EMSCRIPTEN_KEEPALIVE int io_usd_get_index_count() { return index_count; } -extern "C" EMSCRIPTEN_KEEPALIVE int io_usd_get_vertex_count() { return vertex_count; } -extern "C" EMSCRIPTEN_KEEPALIVE float io_usd_get_scale_pos() { return scale_pos; } -extern "C" EMSCRIPTEN_KEEPALIVE int io_usd_get_indices() { return indaOff; } -extern "C" EMSCRIPTEN_KEEPALIVE int io_usd_get_positions() { return posaOff; } -extern "C" EMSCRIPTEN_KEEPALIVE int io_usd_get_normals() { return noraOff; } -extern "C" EMSCRIPTEN_KEEPALIVE int io_usd_get_uvs() { return texaOff; } +extern "C" int io_usd_get_index_count() { return index_count; } +extern "C" int io_usd_get_vertex_count() { return vertex_count; } +extern "C" float io_usd_get_scale_pos() { return scale_pos; } +extern "C" int io_usd_get_indices() { return indaOff; } +extern "C" int io_usd_get_positions() { return posaOff; } +extern "C" int io_usd_get_normals() { return noraOff; } +extern "C" int io_usd_get_uvs() { return texaOff; } diff --git a/armorpaint/Plugins/Sources/proc_xatlas/build.sh b/armorpaint/Plugins/Sources/proc_xatlas/build.sh deleted file mode 100644 index 6bbfcea6..00000000 --- a/armorpaint/Plugins/Sources/proc_xatlas/build.sh +++ /dev/null @@ -1 +0,0 @@ -emcc xatlas.cpp -o xatlas.js -std=c++11 -O3 --closure 1 -s ENVIRONMENT='shell' -s WASM_OBJECT_FILES=0 --llvm-lto 1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ALLOW_MEMORY_GROWTH=1 -fno-rtti -fno-exceptions diff --git a/armorpaint/Plugins/Sources/proc_xatlas/xatlas.cpp b/armorpaint/Plugins/Sources/proc_xatlas/xatlas.cpp index 417b0712..585b4f23 100644 --- a/armorpaint/Plugins/Sources/proc_xatlas/xatlas.cpp +++ b/armorpaint/Plugins/Sources/proc_xatlas/xatlas.cpp @@ -33,12 +33,7 @@ https://github.com/brandonpelfrey/Fast-BVH MIT License Copyright (c) 2012 Brandon Pelfrey */ -#ifdef WITH_PLUGIN_EMBED -#define EMSCRIPTEN_KEEPALIVE #define XA_MULTITHREADED 1 -#else -#include -#endif #include "xatlas.h" #ifndef XATLAS_C_API #define XATLAS_C_API 0 @@ -10063,31 +10058,29 @@ static uint8_t *buffer = NULL; static uint32_t bufferLength = 0; static int vertexCount = 0; static int indexCount = 0; -static int positionsOff = NULL; -static int normalsOff = NULL; -static int indicesOff = NULL; +static int positionsOff = 0; +static int normalsOff = 0; +static int indicesOff = 0; static int allocate(int size) { - #ifdef WITH_PLUGIN_EMBED size += size % 4; // Byte align - #endif bufferLength += size; buffer = buffer == NULL ? (uint8_t *)malloc(bufferLength) : (uint8_t *)realloc(buffer, bufferLength); return bufferLength - size; } -EMSCRIPTEN_KEEPALIVE void proc_xatlas_setVertexCount(int i) { +void proc_xatlas_setVertexCount(int i) { vertexCount = i; positionsOff = allocate(sizeof(float) * vertexCount * 3); normalsOff = allocate(sizeof(float) * vertexCount * 3); } -EMSCRIPTEN_KEEPALIVE void proc_xatlas_setIndexCount(int i) { +void proc_xatlas_setIndexCount(int i) { indexCount = i; indicesOff = allocate(sizeof(unsigned int) * indexCount); } -EMSCRIPTEN_KEEPALIVE int proc_xatlas_setPositions() { return positionsOff; } -EMSCRIPTEN_KEEPALIVE int proc_xatlas_setNormals() { return normalsOff; } -EMSCRIPTEN_KEEPALIVE int proc_xatlas_setIndices() { return indicesOff; } +int proc_xatlas_setPositions() { return positionsOff; } +int proc_xatlas_setNormals() { return normalsOff; } +int proc_xatlas_setIndices() { return indicesOff; } static int vertexCountOut = 0; static int indexCountOut = 0; @@ -10096,16 +10089,16 @@ static int normalsOutOff = 0; static int uvsOutOff = 0; static int indicesOutOff = 0; -EMSCRIPTEN_KEEPALIVE uint8_t *proc_xatlas_getBuffer() { return buffer; } -EMSCRIPTEN_KEEPALIVE uint32_t proc_xatlas_getBufferLength() { return bufferLength; } -EMSCRIPTEN_KEEPALIVE int proc_xatlas_getVertexCount() { return vertexCountOut; } -EMSCRIPTEN_KEEPALIVE int proc_xatlas_getIndexCount() { return indexCountOut; } -EMSCRIPTEN_KEEPALIVE int proc_xatlas_getPositions() { return positionsOutOff; } -EMSCRIPTEN_KEEPALIVE int proc_xatlas_getNormals() { return normalsOutOff; } -EMSCRIPTEN_KEEPALIVE int proc_xatlas_getUVs() { return uvsOutOff; } -EMSCRIPTEN_KEEPALIVE int proc_xatlas_getIndices() { return indicesOutOff; } +uint8_t *proc_xatlas_getBuffer() { return buffer; } +uint32_t proc_xatlas_getBufferLength() { return bufferLength; } +int proc_xatlas_getVertexCount() { return vertexCountOut; } +int proc_xatlas_getIndexCount() { return indexCountOut; } +int proc_xatlas_getPositions() { return positionsOutOff; } +int proc_xatlas_getNormals() { return normalsOutOff; } +int proc_xatlas_getUVs() { return uvsOutOff; } +int proc_xatlas_getIndices() { return indicesOutOff; } -EMSCRIPTEN_KEEPALIVE void proc_xatlas_unwrap() { +void proc_xatlas_unwrap() { atlas = xatlas::Create(); xatlas::MeshDecl meshDecl; meshDecl.vertexCount = vertexCount; @@ -10149,7 +10142,7 @@ EMSCRIPTEN_KEEPALIVE void proc_xatlas_unwrap() { memcpy(buffer + indicesOutOff, mesh.indexArray, sizeof(unsigned int) * indexCountOut); } -EMSCRIPTEN_KEEPALIVE void proc_xatlas_destroy() { +void proc_xatlas_destroy() { xatlas::Destroy(atlas); free(buffer); buffer = NULL; diff --git a/armorpaint/project.js b/armorpaint/project.js index 56c0d4eb..ef5c0de5 100644 --- a/armorpaint/project.js +++ b/armorpaint/project.js @@ -25,16 +25,9 @@ else if (flags.ios) { project.addAssets("Assets/readme/readme_ios.txt", { destination: "{name}" }); } -if (flags.plugin_embed) { - project.addAssets("Assets/plugins/embed/*", { destination: "data/plugins/{name}" }); -} -else { - project.addAssets("Assets/plugins/wasm/*", { destination: "data/plugins/{name}" }); -} - if (flags.physics) { // project.addDefine("arm_physics"); - // project.addAssets("Assets/plugins/wasm/ammo/*", { destination: "data/plugins/{name}" }); + // project.addAssets("Assets/plugins/ammo/*", { destination: "data/plugins/{name}" }); } if (flags.raytrace) { diff --git a/armorsculpt/project.js b/armorsculpt/project.js index f6d08536..a68a4096 100644 --- a/armorsculpt/project.js +++ b/armorsculpt/project.js @@ -25,16 +25,9 @@ else if (flags.ios) { project.addAssets("Assets/readme/readme_ios.txt", { destination: "{name}" }); } -if (flags.plugin_embed) { - project.addAssets("Assets/plugins/embed/*", { destination: "data/plugins/{name}" }); -} -else { - project.addAssets("Assets/plugins/wasm/*", { destination: "data/plugins/{name}" }); -} - if (flags.physics) { project.addDefine("arm_physics"); - project.addAssets("Assets/plugins/wasm/ammo/*", { destination: "data/plugins/{name}" }); + project.addAssets("Assets/plugins/ammo/*", { destination: "data/plugins/{name}" }); } resolve(project); diff --git a/base/Sources/BoxPreferences.ts b/base/Sources/BoxPreferences.ts index 06aafe3b..71788b14 100644 --- a/base/Sources/BoxPreferences.ts +++ b/base/Sources/BoxPreferences.ts @@ -589,7 +589,7 @@ plugin.drawUI = (ui) { => }); } if (ui.button(tr("Import"))) { - UIFiles.show("js,wasm,zip", false, false, (path: string) => { + UIFiles.show("js,zip", false, false, (path: string) => { ImportPlugin.run(path); }); } @@ -603,8 +603,7 @@ plugin.drawUI = (ui) { => let h = Zui.handle("boxpreferences_56", { selected: false }); for (let f of BoxPreferences.filesPlugin) { let isJs = f.endsWith(".js"); - let isWasm = false; //f.endsWith(".wasm"); - if (!isJs && !isWasm) continue; + if (!isJs) continue; let enabled = Config.raw.plugins.indexOf(f) >= 0; h.selected = enabled; let tag = isJs ? f.split(".")[0] : f; diff --git a/base/Sources/Path.ts b/base/Sources/Path.ts index a38d0763..84b78a0b 100644 --- a/base/Sources/Path.ts +++ b/base/Sources/Path.ts @@ -105,8 +105,6 @@ class Path { static isPlugin = (path: string): bool => { let p = path.toLowerCase(); return p.endsWith(".js"); - // p.endsWith(".wasm") || - // p.endsWith(".zip"); } static isJson = (path: string): bool => { diff --git a/base/project.js b/base/project.js index b7e09340..9dc226b4 100644 --- a/base/project.js +++ b/base/project.js @@ -7,7 +7,6 @@ flags.vulkan = process.argv.indexOf("vulkan") >= 0; flags.metal = process.argv.indexOf("metal") >= 0; flags.raytrace = flags.d3d12 || flags.vulkan || flags.metal; flags.snapshot = process.argv.indexOf("--snapshot") >= 0; -flags.plugin_embed = true; // flags.ios; flags.physics = !flags.ios; flags.voxels = !flags.raytrace && !flags.android && !flags.ios; @@ -28,9 +27,6 @@ flags.on_c_project_created = async function(c_project, platform, graphics) { c_project.addDefine("KORE_VKRT"); await c_project.addProject("../" + dir + "/glsl_to_spirv"); } - // if (platform === "ios") { - flags.with_plugin_embed = true; - // } if (flags.with_onnx) { c_project.addDefine("WITH_ONNX"); @@ -56,9 +52,7 @@ flags.on_c_project_created = async function(c_project, platform, graphics) { } } - if (flags.with_plugin_embed) { - await c_project.addProject("../" + dir + "/Plugins"); - } + await c_project.addProject("../" + dir + "/Plugins"); }; let project = new Project("Base");