forked from LeenkxTeam/Leenkx_Examples
update
This commit is contained in:
BIN
wasm_call/Bundled/main.wasm
Normal file
BIN
wasm_call/Bundled/main.wasm
Normal file
Binary file not shown.
1
wasm_call/README.md
Normal file
1
wasm_call/README.md
Normal file
@ -0,0 +1 @@
|
||||
https://github.com/leenkx3d/leenkx/wiki/wasm
|
||||
26
wasm_call/Sources/lnx/MyTrait.hx
Normal file
26
wasm_call/Sources/lnx/MyTrait.hx
Normal file
@ -0,0 +1,26 @@
|
||||
package lnx;
|
||||
|
||||
import iron.data.Data;
|
||||
import iron.data.Wasm;
|
||||
|
||||
class MyTrait extends iron.Trait {
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
notifyOnInit(init);
|
||||
}
|
||||
|
||||
function init() {
|
||||
// Load wasm blob
|
||||
Data.getBlob("main.wasm", blob -> {
|
||||
// Create wasm module
|
||||
var wasm = Wasm.instance(blob);
|
||||
var rot = 0.0;
|
||||
notifyOnUpdate(function() {
|
||||
// Call function from wasm module
|
||||
rot += wasm.exports.test();
|
||||
object.transform.setRotation(0, 0, rot);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
6
wasm_call/main.c
Normal file
6
wasm_call/main.c
Normal file
@ -0,0 +1,6 @@
|
||||
#define WASM_EXPORT __attribute__((visibility("default")))
|
||||
|
||||
WASM_EXPORT
|
||||
float test() {
|
||||
return 0.01f;
|
||||
}
|
||||
BIN
wasm_call/wasm.png
Normal file
BIN
wasm_call/wasm.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
BIN
wasm_call/wasm_call.blend
Normal file
BIN
wasm_call/wasm_call.blend
Normal file
Binary file not shown.
Reference in New Issue
Block a user