forked from LeenkxTeam/Leenkx_Examples
update
This commit is contained in:
14
call_hx/Bundled/my_plugin.js
Normal file
14
call_hx/Bundled/my_plugin.js
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
// Call Plugin class exposed from Haxe
|
||||
|
||||
var plugin = new arm.Plugin();
|
||||
plugin.hello();
|
||||
|
||||
var scene = plugin.scene();
|
||||
var rot = 0.0;
|
||||
|
||||
plugin.update = function() {
|
||||
rot += 0.01;
|
||||
var o = scene.getChild("Cube");
|
||||
o.transform.setRotation(0, 0, rot);
|
||||
}
|
||||
2
call_hx/README.md
Normal file
2
call_hx/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
Check console.
|
||||
https://github.com/leenkx3d/leenkx/wiki/js
|
||||
11
call_hx/Sources/lnx/EvalJS.hx
Normal file
11
call_hx/Sources/lnx/EvalJS.hx
Normal file
@ -0,0 +1,11 @@
|
||||
package lnx;
|
||||
|
||||
class EvalJS {
|
||||
|
||||
public function new() {
|
||||
// Evaluate bundled JS, usually you would embed JS into .html file instead
|
||||
iron.data.Data.getBlob("my_plugin.js", function(blob:kha.Blob) {
|
||||
js.Syntax.code("(1, eval)({0})", blob.toString());
|
||||
});
|
||||
}
|
||||
}
|
||||
24
call_hx/Sources/lnx/Plugin.hx
Normal file
24
call_hx/Sources/lnx/Plugin.hx
Normal file
@ -0,0 +1,24 @@
|
||||
package lnx;
|
||||
|
||||
// Expose this class for easy access from JS
|
||||
|
||||
@:expose
|
||||
class Plugin extends iron.Trait {
|
||||
|
||||
var update:Void->Void = null;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
notifyOnUpdate(function() {
|
||||
if (update != null) update();
|
||||
});
|
||||
}
|
||||
|
||||
public function hello() {
|
||||
trace("world");
|
||||
}
|
||||
|
||||
public function scene() {
|
||||
return iron.Scene.active;
|
||||
}
|
||||
}
|
||||
BIN
call_hx/call_hx.blend
Normal file
BIN
call_hx/call_hx.blend
Normal file
Binary file not shown.
Reference in New Issue
Block a user