Open cdrake opened 3 years ago
It looks like the WASM coding is only loaded once. Most real world problems will have larger images and refresh contrast brightness for multiple images. Did you test the performance?
Alternatively, is it faster to encode the warm as base64 which allows you to embed it in the JS file rather than loading as a separate file. Here is how I converted wasm to base64
openssl base64 -in x2.wasm -out fx.txt
The javascript code looks like this (we load the base 64, but still need to compile it once):
var wasmB64 =
`AGFzbQEAAAABjICAgAACYAF/AX9gAn9/AX0Dg4CAgAACAAEEhICAgAABcAAABYOA
gIAAAQABBoGAgIAAAAengICAAAMGbWVtb3J5AgALX1o3c3F1YXJlcmkAAAxfWjZz
dW1fdXBQZmkAAQrGgICAAAKHgICAAAAgACAAbAu0gICAAAEBfUMAAAAAIQICQCAB
QQFIDQADQCACIAAqAgCSIQIgAEEEaiEAIAFBf2oiAQ0ACwsgAgs=`
var url57 = 'data:application/wasm;base64,' + wasmB64;
let squarer;
function loadWebAssembly(fileName) {
return fetch(fileName)
.then(response => response.arrayBuffer())
.then(buffer => WebAssembly.compile(buffer))
.then(module => {return new WebAssembly.Instance(module) });
}
await loadWebAssembly(url57)
There is a penalty to initialization time since we are loading the WASM. Right now, the robust range function does not support ignoreZeroVoxels or percentileFrac but we can add them in a future commit.