forked from LeenkxTeam/Leenkx_Examples
update
This commit is contained in:
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user