{"id":314517,"date":"2020-12-08T15:00:30","date_gmt":"2020-12-08T15:00:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=314517"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=314517","title":{"rendered":"Wasm \u0432 Armory Engine"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b50\/58c\/659\/b5058c659007ed173de1a46e18ee1c2c.jpg\" width=\"1600\" height=\"720\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u0432 \u0442\u0430\u043d\u043a\u0435 &#8212; wasm \u0438\u043b\u0438 WebAssembly \u044d\u0442\u043e \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0438\u0437\u043a\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0434\u043b\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0435\u043a\u043e\u0432\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0440\u0430\u0437 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u043a\u0430\u043a \u043f\u043e\u0440\u0442\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a&nbsp;\u0421\u0438,&nbsp;C++,&nbsp;C#,&nbsp;Rust,&nbsp;Go. \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439 \u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u044b\u0439 \u043a\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f wasm. \u041d\u0430\u0448 Armory \u0442\u043e\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 wasm. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u043c\u0443 \u0434\u0432\u0438\u0436\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Krom.<\/p>\n<h3>Traits \u043d\u0430 \u0421 \u0438 Rust<\/h3>\n<p>\u0415\u0449\u0435 wasm \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 traits \u0438\u043b\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a\u0443\u0431\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0421\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a\u0443\u0431\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>#define WASM_EXPORT __attribute__((visibility(\"default\")))  \/\/ Declare Armory API used in this module \/\/ github.com\/armory3d\/armory\/blob\/master\/Sources\/armory\/trait\/internal\/wasm_api.h void notify_on_update(void* f); int get_object(const char* name); void set_transform(int object, float x, float y, float z, \tfloat rx, float ry, float rz, float sx, float sy, float sz);  WASM_EXPORT void update() { \tstatic float rot = 0.0f; \trot += 0.01f; \tset_transform(get_object(\"Cube\"), 0, 0, 0, 0, 0, rot, 1, 1, 1); \/\/ Set cube rotation }  \/\/ Include main function, Armory calls it when trait is instantiated WASM_EXPORT int main() { \tnotify_on_update(update); \/\/ Register callback \treturn 0; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a \u043d\u0430 \u0421 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <a href=\"https:\/\/webassembly.studio\/?f=kl1f79ll4x\" rel=\"noopener noreferrer nofollow\">webassembly.studio<\/a>. \u041f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f wasm \u0444\u0430\u0439\u043b \u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <em>blend_location\/Bundled. <\/em><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 blender \u043a\u0443\u0431, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 <em>properties &#8212; Object &#8212; Armory Traits, <\/em>\u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u0443\u044e wasm traits, \u0432 <em>modules<\/em> \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u043d\u0430\u0448 wasm \u0444\u0430\u0439\u043b. \u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c F5 \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u0443\u0431. \u041f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c <a href=\"https:\/\/github.com\/armory3d\/armory_examples\/tree\/master\/web_assembly\/c_trait\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f46\/19e\/a2d\/f4619ea2d5ac72f86ee28a650a807392.jpg\" width=\"1920\" height=\"1017\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 Rust.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043d\u0430 Rust<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>extern {   fn notify_on_update(f: extern fn() -&gt; ()) -&gt; ();   fn get_object(name: *const i8) -&gt; i32;   fn set_transform(object: i32, x: f32, y: f32, z: f32, rx: f32, ry: f32, rz: f32, sx: f32, sy: f32, sz: f32) -&gt; (); }  #[no_mangle] pub extern \"C\" fn update() -&gt; () {   unsafe {     let name = std::ffi::CString::new(\"Cube\").unwrap();     let object = get_object(name.as_ptr());     static mut rot: f32 = 0.1;     rot += 0.01;     set_transform(object, 0.0, 0.0, 0.0, 0.0, 0.0, rot, 1.0, 1.0, 1.0);   } }  #[no_mangle] pub extern \"C\" fn main() -&gt; i32 {   unsafe {     notify_on_update(update);   }   return 0; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0432 <em>Bundled<\/em>.<\/p>\n<h3>\u0412\u044b\u0437\u043e\u0432 wasm \u043d\u0430 Haxe <\/h3>\n<p>Wasm \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0438\u0437 properties \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432 haxe. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0421.<\/p>\n<pre><code>#define WASM_EXPORT __attribute__((visibility(\"default\")))  WASM_EXPORT float test() { \treturn 0.01f; }<\/code><\/pre>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a \u0432  <a href=\"https:\/\/webassembly.studio\/?f=kl1f79ll4x\" rel=\"noopener noreferrer nofollow\">webassembly.studio<\/a>. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0432 <em>blend_location\/Bundled.<\/em><\/p>\n<p>\u0412\u044b\u0437\u043e\u0432 test() \u0438\u0437 Haxe.<\/p>\n<pre><code>package arm; import iron.data.*  class MyTrait extends iron.Trait { \tpublic function new() { \t\tsuper(); \t\tnotifyOnInit(init); \t}  \tfunction init() { \t\tData.getBlob(\"main.wasm\", function(b:kha.Blob) { \/\/ Load wasm blob \t\t\tvar wasm = Wasm.instance(b); \/\/ Create wasm module \t\t\tvar rot = 0.0; \t\t\tnotifyOnUpdate(function() { \t\t\t\trot += wasm.exports.test(); \/\/ Call function from wasm module! \t\t\t\tobject.transform.setRotation(0, 0, rot); \t\t\t}); \t\t}); \t} }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c <a href=\"https:\/\/github.com\/armory3d\/armory_examples\/tree\/master\/web_assembly\/call_wasm\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>.<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/529784\/\" rel=\"noopener noreferrer nofollow\">Armory Engine. \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/529784\/\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0440\u043e\u0432\u043d\u044f \u0432 Armory<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/531670\/\" rel=\"noopener noreferrer nofollow\">\u041e\u0441\u043d\u043e\u0432\u044b Armory. Traits<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/531964\/\"> https:\/\/habr.com\/ru\/post\/531964\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u0432 \u0442\u0430\u043d\u043a\u0435 &#8212; wasm \u0438\u043b\u0438 WebAssembly \u044d\u0442\u043e \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0438\u0437\u043a\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0434\u043b\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0435\u043a\u043e\u0432\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0440\u0430\u0437 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u043a\u0430\u043a \u043f\u043e\u0440\u0442\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a&nbsp;\u0421\u0438,&nbsp;C++,&nbsp;C#,&nbsp;Rust,&nbsp;Go. \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439 \u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u044b\u0439 \u043a\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f wasm. \u041d\u0430\u0448 Armory \u0442\u043e\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 wasm. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u043c\u0443 \u0434\u0432\u0438\u0436\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Krom.<\/p>\n<h3>Traits \u043d\u0430 \u0421 \u0438 Rust<\/h3>\n<p>\u0415\u0449\u0435 wasm \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 traits \u0438\u043b\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a\u0443\u0431\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0421\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a\u0443\u0431\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>#define WASM_EXPORT __attribute__((visibility(\"default\")))  \/\/ Declare Armory API used in this module \/\/ github.com\/armory3d\/armory\/blob\/master\/Sources\/armory\/trait\/internal\/wasm_api.h void notify_on_update(void* f); int get_object(const char* name); void set_transform(int object, float x, float y, float z, \tfloat rx, float ry, float rz, float sx, float sy, float sz);  WASM_EXPORT void update() { \tstatic float rot = 0.0f; \trot += 0.01f; \tset_transform(get_object(\"Cube\"), 0, 0, 0, 0, 0, rot, 1, 1, 1); \/\/ Set cube rotation }  \/\/ Include main function, Armory calls it when trait is instantiated WASM_EXPORT int main() { \tnotify_on_update(update); \/\/ Register callback \treturn 0; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a \u043d\u0430 \u0421 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <a href=\"https:\/\/webassembly.studio\/?f=kl1f79ll4x\" rel=\"noopener noreferrer nofollow\">webassembly.studio<\/a>. \u041f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f wasm \u0444\u0430\u0439\u043b \u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <em>blend_location\/Bundled. <\/em><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 blender \u043a\u0443\u0431, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 <em>properties &#8212; Object &#8212; Armory Traits, <\/em>\u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u0443\u044e wasm traits, \u0432 <em>modules<\/em> \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u043d\u0430\u0448 wasm \u0444\u0430\u0439\u043b. \u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c F5 \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u0443\u0431. \u041f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c <a href=\"https:\/\/github.com\/armory3d\/armory_examples\/tree\/master\/web_assembly\/c_trait\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>. <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 Rust.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043d\u0430 Rust<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>extern {   fn notify_on_update(f: extern fn() -&gt; ()) -&gt; ();   fn get_object(name: *const i8) -&gt; i32;   fn set_transform(object: i32, x: f32, y: f32, z: f32, rx: f32, ry: f32, rz: f32, sx: f32, sy: f32, sz: f32) -&gt; (); }  #[no_mangle] pub extern \"C\" fn update() -&gt; () {   unsafe {     let name = std::ffi::CString::new(\"Cube\").unwrap();     let object = get_object(name.as_ptr());     static mut rot: f32 = 0.1;     rot += 0.01;     set_transform(object, 0.0, 0.0, 0.0, 0.0, 0.0, rot, 1.0, 1.0, 1.0);   } }  #[no_mangle] pub extern \"C\" fn main() -&gt; i32 {   unsafe {     notify_on_update(update);   }   return 0; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0432 <em>Bundled<\/em>.<\/p>\n<h3>\u0412\u044b\u0437\u043e\u0432 wasm \u043d\u0430 Haxe <\/h3>\n<p>Wasm \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0438\u0437 properties \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432 haxe. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0421.<\/p>\n<pre><code>#define WASM_EXPORT __attribute__((visibility(\"default\")))  WASM_EXPORT float test() { \treturn 0.01f; }<\/code><\/pre>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a \u0432  <a href=\"https:\/\/webassembly.studio\/?f=kl1f79ll4x\" rel=\"noopener noreferrer nofollow\">webassembly.studio<\/a>. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0432 <em>blend_location\/Bundled.<\/em><\/p>\n<p>\u0412\u044b\u0437\u043e\u0432 test() \u0438\u0437 Haxe.<\/p>\n<pre><code>package arm; import iron.data.*  class MyTrait extends iron.Trait { \tpublic function new() { \t\tsuper(); \t\tnotifyOnInit(init); \t}  \tfunction init() { \t\tData.getBlob(\"main.wasm\", function(b:kha.Blob) { \/\/ Load wasm blob \t\t\tvar wasm = Wasm.instance(b); \/\/ Create wasm module \t\t\tvar rot = 0.0; \t\t\tnotifyOnUpdate(function() { \t\t\t\trot += wasm.exports.test(); \/\/ Call function from wasm module! \t\t\t\tobject.transform.setRotation(0, 0, rot); \t\t\t}); \t\t}); \t} }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c <a href=\"https:\/\/github.com\/armory3d\/armory_examples\/tree\/master\/web_assembly\/call_wasm\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>.<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/529784\/\" rel=\"noopener noreferrer nofollow\">Armory Engine. \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/529784\/\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0440\u043e\u0432\u043d\u044f \u0432 Armory<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/531670\/\" rel=\"noopener noreferrer nofollow\">\u041e\u0441\u043d\u043e\u0432\u044b Armory. Traits<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/531964\/\"> https:\/\/habr.com\/ru\/post\/531964\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-314517","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/314517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=314517"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/314517\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=314517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=314517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=314517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}