plugins.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. #include <v8.h>
  2. #include <kinc/log.h>
  3. using namespace v8;
  4. static Isolate *isolate;
  5. extern "C" {
  6. void proc_xatlas_setVertexCount(int i);
  7. void proc_xatlas_setIndexCount(int i);
  8. int proc_xatlas_setPositions();
  9. int proc_xatlas_setNormals();
  10. int proc_xatlas_setIndices();
  11. uint8_t *proc_xatlas_getBuffer();
  12. uint32_t proc_xatlas_getBufferLength();
  13. int proc_xatlas_getVertexCount();
  14. int proc_xatlas_getIndexCount();
  15. int proc_xatlas_getPositions();
  16. int proc_xatlas_getNormals();
  17. int proc_xatlas_getUVs();
  18. int proc_xatlas_getIndices();
  19. void proc_xatlas_unwrap();
  20. void proc_xatlas_destroy();
  21. uint8_t *io_svg_getBuffer();
  22. uint32_t io_svg_getBufferLength();
  23. int io_svg_init(int i);
  24. void io_svg_parse();
  25. int io_svg_get_pixels_w();
  26. int io_svg_get_pixels_h();
  27. int io_svg_get_pixels();
  28. void io_svg_destroy();
  29. uint8_t *io_gltf_getBuffer();
  30. uint32_t io_gltf_getBufferLength();
  31. int io_gltf_init(int i);
  32. void io_gltf_parse();
  33. int io_gltf_get_vertex_count();
  34. int io_gltf_get_index_count();
  35. int io_gltf_get_indices();
  36. int io_gltf_get_positions();
  37. int io_gltf_get_normals();
  38. int io_gltf_get_uvs();
  39. float io_gltf_get_scale_pos();
  40. void io_gltf_destroy();
  41. uint8_t *io_usd_getBuffer();
  42. uint32_t io_usd_getBufferLength();
  43. int io_usd_init(int i);
  44. void io_usd_parse();
  45. int io_usd_get_vertex_count();
  46. int io_usd_get_index_count();
  47. int io_usd_get_indices();
  48. int io_usd_get_positions();
  49. int io_usd_get_normals();
  50. int io_usd_get_uvs();
  51. float io_usd_get_scale_pos();
  52. void io_usd_destroy();
  53. uint8_t *io_fbx_getBuffer();
  54. uint32_t io_fbx_getBufferLength();
  55. int io_fbx_init(int i);
  56. void io_fbx_parse();
  57. int io_fbx_get_vertex_count();
  58. int io_fbx_get_index_count();
  59. int io_fbx_get_indices();
  60. int io_fbx_get_positions();
  61. int io_fbx_get_normals();
  62. int io_fbx_get_uvs();
  63. int io_fbx_get_colors();
  64. float io_fbx_get_scale_pos();
  65. float *io_fbx_get_transform();
  66. char *io_fbx_get_name();
  67. void io_fbx_destroy();
  68. bool io_fbx_has_next();
  69. }
  70. namespace {
  71. void krom_uv_unwrap_buffer(const FunctionCallbackInfo<Value> &args) {
  72. HandleScope scope(args.GetIsolate());
  73. std::unique_ptr<v8::BackingStore> backing = v8::ArrayBuffer::NewBackingStore(proc_xatlas_getBuffer(), proc_xatlas_getBufferLength(), [](void*, size_t, void*) {}, nullptr);
  74. Local<ArrayBuffer> buffer = ArrayBuffer::New(isolate, std::move(backing));
  75. args.GetReturnValue().Set(buffer);
  76. }
  77. void krom_uv_unwrap_setVertexCount(const FunctionCallbackInfo<Value> &args) {
  78. HandleScope scope(args.GetIsolate());
  79. int i = args[0]->ToInt32(isolate->GetCurrentContext()).ToLocalChecked()->Value();
  80. proc_xatlas_setVertexCount(i);
  81. }
  82. void krom_uv_unwrap_setIndexCount(const FunctionCallbackInfo<Value> &args) {
  83. HandleScope scope(args.GetIsolate());
  84. int i = args[0]->ToInt32(isolate->GetCurrentContext()).ToLocalChecked()->Value();
  85. proc_xatlas_setIndexCount(i);
  86. }
  87. void krom_uv_unwrap_setPositions(const FunctionCallbackInfo<Value> &args) {
  88. HandleScope scope(args.GetIsolate());
  89. int i = proc_xatlas_setPositions();
  90. args.GetReturnValue().Set(Int32::New(isolate, i));
  91. }
  92. void krom_uv_unwrap_setNormals(const FunctionCallbackInfo<Value> &args) {
  93. HandleScope scope(args.GetIsolate());
  94. int i = proc_xatlas_setNormals();
  95. args.GetReturnValue().Set(Int32::New(isolate, i));
  96. }
  97. void krom_uv_unwrap_setIndices(const FunctionCallbackInfo<Value> &args) {
  98. HandleScope scope(args.GetIsolate());
  99. int i = proc_xatlas_setIndices();
  100. args.GetReturnValue().Set(Int32::New(isolate, i));
  101. }
  102. void krom_uv_unwrap_getVertexCount(const FunctionCallbackInfo<Value> &args) {
  103. HandleScope scope(args.GetIsolate());
  104. int i = proc_xatlas_getVertexCount();
  105. args.GetReturnValue().Set(Int32::New(isolate, i));
  106. }
  107. void krom_uv_unwrap_getIndexCount(const FunctionCallbackInfo<Value> &args) {
  108. HandleScope scope(args.GetIsolate());
  109. int i = proc_xatlas_getIndexCount();
  110. args.GetReturnValue().Set(Int32::New(isolate, i));
  111. }
  112. void krom_uv_unwrap_getPositions(const FunctionCallbackInfo<Value> &args) {
  113. HandleScope scope(args.GetIsolate());
  114. int i = proc_xatlas_getPositions();
  115. args.GetReturnValue().Set(Int32::New(isolate, i));
  116. }
  117. void krom_uv_unwrap_getNormals(const FunctionCallbackInfo<Value> &args) {
  118. HandleScope scope(args.GetIsolate());
  119. int i = proc_xatlas_getNormals();
  120. args.GetReturnValue().Set(Int32::New(isolate, i));
  121. }
  122. void krom_uv_unwrap_getUVs(const FunctionCallbackInfo<Value> &args) {
  123. HandleScope scope(args.GetIsolate());
  124. int i = proc_xatlas_getUVs();
  125. args.GetReturnValue().Set(Int32::New(isolate, i));
  126. }
  127. void krom_uv_unwrap_getIndices(const FunctionCallbackInfo<Value> &args) {
  128. HandleScope scope(args.GetIsolate());
  129. int i = proc_xatlas_getIndices();
  130. args.GetReturnValue().Set(Int32::New(isolate, i));
  131. }
  132. void krom_uv_unwrap_unwrap(const FunctionCallbackInfo<Value> &args) {
  133. HandleScope scope(args.GetIsolate());
  134. proc_xatlas_unwrap();
  135. }
  136. void krom_uv_unwrap_destroy(const FunctionCallbackInfo<Value> &args) {
  137. HandleScope scope(args.GetIsolate());
  138. proc_xatlas_destroy();
  139. }
  140. void krom_import_svg_buffer(const FunctionCallbackInfo<Value> &args) {
  141. HandleScope scope(args.GetIsolate());
  142. std::unique_ptr<v8::BackingStore> backing = v8::ArrayBuffer::NewBackingStore(io_svg_getBuffer(), io_svg_getBufferLength(), [](void*, size_t, void*) {}, nullptr);
  143. Local<ArrayBuffer> buffer = ArrayBuffer::New(isolate, std::move(backing));
  144. args.GetReturnValue().Set(buffer);
  145. }
  146. void krom_import_svg_init(const FunctionCallbackInfo<Value> &args) {
  147. HandleScope scope(args.GetIsolate());
  148. int i = args[0]->ToInt32(isolate->GetCurrentContext()).ToLocalChecked()->Value();
  149. int j = io_svg_init(i);
  150. args.GetReturnValue().Set(Int32::New(isolate, j));
  151. }
  152. void krom_import_svg_parse(const FunctionCallbackInfo<Value> &args) {
  153. HandleScope scope(args.GetIsolate());
  154. io_svg_parse();
  155. }
  156. void krom_import_svg_get_pixels_w(const FunctionCallbackInfo<Value> &args) {
  157. HandleScope scope(args.GetIsolate());
  158. int i = io_svg_get_pixels_w();
  159. args.GetReturnValue().Set(Int32::New(isolate, i));
  160. }
  161. void krom_import_svg_get_pixels_h(const FunctionCallbackInfo<Value> &args) {
  162. HandleScope scope(args.GetIsolate());
  163. int i = io_svg_get_pixels_h();
  164. args.GetReturnValue().Set(Int32::New(isolate, i));
  165. }
  166. void krom_import_svg_get_pixels(const FunctionCallbackInfo<Value> &args) {
  167. HandleScope scope(args.GetIsolate());
  168. int i = io_svg_get_pixels();
  169. args.GetReturnValue().Set(Int32::New(isolate, i));
  170. }
  171. void krom_import_svg_destroy(const FunctionCallbackInfo<Value> &args) {
  172. HandleScope scope(args.GetIsolate());
  173. io_svg_destroy();
  174. }
  175. void krom_import_gltf_buffer(const FunctionCallbackInfo<Value> &args) {
  176. HandleScope scope(args.GetIsolate());
  177. std::unique_ptr<v8::BackingStore> backing = v8::ArrayBuffer::NewBackingStore(io_gltf_getBuffer(), io_gltf_getBufferLength(), [](void*, size_t, void*) {}, nullptr);
  178. Local<ArrayBuffer> buffer = ArrayBuffer::New(isolate, std::move(backing));
  179. args.GetReturnValue().Set(buffer);
  180. }
  181. void krom_import_gltf_init(const FunctionCallbackInfo<Value> &args) {
  182. HandleScope scope(args.GetIsolate());
  183. int i = args[0]->ToInt32(isolate->GetCurrentContext()).ToLocalChecked()->Value();
  184. int j = io_gltf_init(i);
  185. args.GetReturnValue().Set(Int32::New(isolate, j));
  186. }
  187. void krom_import_gltf_parse(const FunctionCallbackInfo<Value> &args) {
  188. HandleScope scope(args.GetIsolate());
  189. io_gltf_parse();
  190. }
  191. void krom_import_gltf_get_vertex_count(const FunctionCallbackInfo<Value> &args) {
  192. HandleScope scope(args.GetIsolate());
  193. int i = io_gltf_get_vertex_count();
  194. args.GetReturnValue().Set(Int32::New(isolate, i));
  195. }
  196. void krom_import_gltf_get_index_count(const FunctionCallbackInfo<Value> &args) {
  197. HandleScope scope(args.GetIsolate());
  198. int i = io_gltf_get_index_count();
  199. args.GetReturnValue().Set(Int32::New(isolate, i));
  200. }
  201. void krom_import_gltf_get_indices(const FunctionCallbackInfo<Value> &args) {
  202. HandleScope scope(args.GetIsolate());
  203. int i = io_gltf_get_indices();
  204. args.GetReturnValue().Set(Int32::New(isolate, i));
  205. }
  206. void krom_import_gltf_get_positions(const FunctionCallbackInfo<Value> &args) {
  207. HandleScope scope(args.GetIsolate());
  208. int i = io_gltf_get_positions();
  209. args.GetReturnValue().Set(Int32::New(isolate, i));
  210. }
  211. void krom_import_gltf_get_normals(const FunctionCallbackInfo<Value> &args) {
  212. HandleScope scope(args.GetIsolate());
  213. int i = io_gltf_get_normals();
  214. args.GetReturnValue().Set(Int32::New(isolate, i));
  215. }
  216. void krom_import_gltf_get_uvs(const FunctionCallbackInfo<Value> &args) {
  217. HandleScope scope(args.GetIsolate());
  218. int i = io_gltf_get_uvs();
  219. args.GetReturnValue().Set(Int32::New(isolate, i));
  220. }
  221. void krom_import_gltf_get_scale_pos(const FunctionCallbackInfo<Value> &args) {
  222. HandleScope scope(args.GetIsolate());
  223. float f = io_gltf_get_scale_pos();
  224. args.GetReturnValue().Set(Number::New(isolate, f));
  225. }
  226. void krom_import_gltf_destroy(const FunctionCallbackInfo<Value> &args) {
  227. HandleScope scope(args.GetIsolate());
  228. io_gltf_destroy();
  229. }
  230. void krom_import_usdc_buffer(const FunctionCallbackInfo<Value> &args) {
  231. HandleScope scope(args.GetIsolate());
  232. std::unique_ptr<v8::BackingStore> backing = v8::ArrayBuffer::NewBackingStore(io_usd_getBuffer(), io_usd_getBufferLength(), [](void*, size_t, void*) {}, nullptr);
  233. Local<ArrayBuffer> buffer = ArrayBuffer::New(isolate, std::move(backing));
  234. args.GetReturnValue().Set(buffer);
  235. }
  236. void krom_import_usdc_init(const FunctionCallbackInfo<Value> &args) {
  237. HandleScope scope(args.GetIsolate());
  238. int i = args[0]->ToInt32(isolate->GetCurrentContext()).ToLocalChecked()->Value();
  239. int j = io_usd_init(i);
  240. args.GetReturnValue().Set(Int32::New(isolate, j));
  241. }
  242. void krom_import_usdc_parse(const FunctionCallbackInfo<Value> &args) {
  243. HandleScope scope(args.GetIsolate());
  244. io_usd_parse();
  245. }
  246. void krom_import_usdc_get_vertex_count(const FunctionCallbackInfo<Value> &args) {
  247. HandleScope scope(args.GetIsolate());
  248. int i = io_usd_get_vertex_count();
  249. args.GetReturnValue().Set(Int32::New(isolate, i));
  250. }
  251. void krom_import_usdc_get_index_count(const FunctionCallbackInfo<Value> &args) {
  252. HandleScope scope(args.GetIsolate());
  253. int i = io_usd_get_index_count();
  254. args.GetReturnValue().Set(Int32::New(isolate, i));
  255. }
  256. void krom_import_usdc_get_indices(const FunctionCallbackInfo<Value> &args) {
  257. HandleScope scope(args.GetIsolate());
  258. int i = io_usd_get_indices();
  259. args.GetReturnValue().Set(Int32::New(isolate, i));
  260. }
  261. void krom_import_usdc_get_positions(const FunctionCallbackInfo<Value> &args) {
  262. HandleScope scope(args.GetIsolate());
  263. int i = io_usd_get_positions();
  264. args.GetReturnValue().Set(Int32::New(isolate, i));
  265. }
  266. void krom_import_usdc_get_normals(const FunctionCallbackInfo<Value> &args) {
  267. HandleScope scope(args.GetIsolate());
  268. int i = io_usd_get_normals();
  269. args.GetReturnValue().Set(Int32::New(isolate, i));
  270. }
  271. void krom_import_usdc_get_uvs(const FunctionCallbackInfo<Value> &args) {
  272. HandleScope scope(args.GetIsolate());
  273. int i = io_usd_get_uvs();
  274. args.GetReturnValue().Set(Int32::New(isolate, i));
  275. }
  276. void krom_import_usdc_get_scale_pos(const FunctionCallbackInfo<Value> &args) {
  277. HandleScope scope(args.GetIsolate());
  278. float f = io_usd_get_scale_pos();
  279. args.GetReturnValue().Set(Number::New(isolate, f));
  280. }
  281. void krom_import_usdc_destroy(const FunctionCallbackInfo<Value> &args) {
  282. HandleScope scope(args.GetIsolate());
  283. io_usd_destroy();
  284. }
  285. void krom_import_fbx_buffer(const FunctionCallbackInfo<Value> &args) {
  286. HandleScope scope(args.GetIsolate());
  287. std::unique_ptr<v8::BackingStore> backing = v8::ArrayBuffer::NewBackingStore(io_fbx_getBuffer(), io_fbx_getBufferLength(), [](void*, size_t, void*) {}, nullptr);
  288. Local<ArrayBuffer> buffer = ArrayBuffer::New(isolate, std::move(backing));
  289. args.GetReturnValue().Set(buffer);
  290. }
  291. void krom_import_fbx_init(const FunctionCallbackInfo<Value> &args) {
  292. HandleScope scope(args.GetIsolate());
  293. int i = args[0]->ToInt32(isolate->GetCurrentContext()).ToLocalChecked()->Value();
  294. int j = io_fbx_init(i);
  295. args.GetReturnValue().Set(Int32::New(isolate, j));
  296. }
  297. void krom_import_fbx_parse(const FunctionCallbackInfo<Value> &args) {
  298. HandleScope scope(args.GetIsolate());
  299. io_fbx_parse();
  300. }
  301. void krom_import_fbx_get_vertex_count(const FunctionCallbackInfo<Value> &args) {
  302. HandleScope scope(args.GetIsolate());
  303. int i = io_fbx_get_vertex_count();
  304. args.GetReturnValue().Set(Int32::New(isolate, i));
  305. }
  306. void krom_import_fbx_get_index_count(const FunctionCallbackInfo<Value> &args) {
  307. HandleScope scope(args.GetIsolate());
  308. int i = io_fbx_get_index_count();
  309. args.GetReturnValue().Set(Int32::New(isolate, i));
  310. }
  311. void krom_import_fbx_get_indices(const FunctionCallbackInfo<Value> &args) {
  312. HandleScope scope(args.GetIsolate());
  313. int i = io_fbx_get_indices();
  314. args.GetReturnValue().Set(Int32::New(isolate, i));
  315. }
  316. void krom_import_fbx_get_positions(const FunctionCallbackInfo<Value> &args) {
  317. HandleScope scope(args.GetIsolate());
  318. int i = io_fbx_get_positions();
  319. args.GetReturnValue().Set(Int32::New(isolate, i));
  320. }
  321. void krom_import_fbx_get_normals(const FunctionCallbackInfo<Value> &args) {
  322. HandleScope scope(args.GetIsolate());
  323. int i = io_fbx_get_normals();
  324. args.GetReturnValue().Set(Int32::New(isolate, i));
  325. }
  326. void krom_import_fbx_get_uvs(const FunctionCallbackInfo<Value> &args) {
  327. HandleScope scope(args.GetIsolate());
  328. int i = io_fbx_get_uvs();
  329. args.GetReturnValue().Set(Int32::New(isolate, i));
  330. }
  331. void krom_import_fbx_get_colors(const FunctionCallbackInfo<Value> &args) {
  332. HandleScope scope(args.GetIsolate());
  333. int i = io_fbx_get_colors();
  334. args.GetReturnValue().Set(Int32::New(isolate, i));
  335. }
  336. void krom_import_fbx_get_scale_pos(const FunctionCallbackInfo<Value> &args) {
  337. HandleScope scope(args.GetIsolate());
  338. float f = io_fbx_get_scale_pos();
  339. args.GetReturnValue().Set(Number::New(isolate, f));
  340. }
  341. void krom_import_fbx_get_transform(const FunctionCallbackInfo<Value> &args) {
  342. HandleScope scope(args.GetIsolate());
  343. float *f = io_fbx_get_transform();
  344. std::unique_ptr<v8::BackingStore> backing = v8::ArrayBuffer::NewBackingStore(
  345. f, 16 * sizeof(float), [](void *, size_t, void *) {}, nullptr);
  346. Local<ArrayBuffer> abuffer = ArrayBuffer::New(isolate, std::move(backing));
  347. args.GetReturnValue().Set(Float32Array::New(abuffer, 0, 16));
  348. }
  349. void krom_import_fbx_get_name(const FunctionCallbackInfo<Value> &args) {
  350. HandleScope scope(args.GetIsolate());
  351. char *name = io_fbx_get_name();
  352. args.GetReturnValue().Set(String::NewFromUtf8(isolate, name).ToLocalChecked());
  353. }
  354. void krom_import_fbx_destroy(const FunctionCallbackInfo<Value> &args) {
  355. HandleScope scope(args.GetIsolate());
  356. io_fbx_destroy();
  357. }
  358. void krom_import_fbx_has_next(const FunctionCallbackInfo<Value> &args) {
  359. HandleScope scope(args.GetIsolate());
  360. int i = io_fbx_has_next();
  361. args.GetReturnValue().Set(Int32::New(isolate, i));
  362. }
  363. }
  364. #define SET_FUNCTION(object, name, fn)\
  365. object->Set(String::NewFromUtf8(isolate, name).ToLocalChecked(),\
  366. FunctionTemplate::New(isolate, fn, Local<v8::Value>(), Local<v8::Signature>(), 0,\
  367. v8::ConstructorBehavior::kThrow, v8::SideEffectType::kHasNoSideEffect, nullptr))
  368. void plugin_embed(Isolate *_isolate, Local<ObjectTemplate> global) {
  369. isolate = _isolate;
  370. Isolate::Scope isolate_scope(isolate);
  371. HandleScope handle_scope(isolate);
  372. Local<ObjectTemplate> krom_uv_unwrap = ObjectTemplate::New(isolate);
  373. SET_FUNCTION(krom_uv_unwrap, "_buffer", krom_uv_unwrap_buffer);
  374. SET_FUNCTION(krom_uv_unwrap, "_setVertexCount", krom_uv_unwrap_setVertexCount);
  375. SET_FUNCTION(krom_uv_unwrap, "_setIndexCount", krom_uv_unwrap_setIndexCount);
  376. SET_FUNCTION(krom_uv_unwrap, "_setPositions", krom_uv_unwrap_setPositions);
  377. SET_FUNCTION(krom_uv_unwrap, "_setNormals", krom_uv_unwrap_setNormals);
  378. SET_FUNCTION(krom_uv_unwrap, "_setIndices", krom_uv_unwrap_setIndices);
  379. SET_FUNCTION(krom_uv_unwrap, "_getVertexCount", krom_uv_unwrap_getVertexCount);
  380. SET_FUNCTION(krom_uv_unwrap, "_getIndexCount", krom_uv_unwrap_getIndexCount);
  381. SET_FUNCTION(krom_uv_unwrap, "_getPositions", krom_uv_unwrap_getPositions);
  382. SET_FUNCTION(krom_uv_unwrap, "_getNormals", krom_uv_unwrap_getNormals);
  383. SET_FUNCTION(krom_uv_unwrap, "_getUVs", krom_uv_unwrap_getUVs);
  384. SET_FUNCTION(krom_uv_unwrap, "_getIndices", krom_uv_unwrap_getIndices);
  385. SET_FUNCTION(krom_uv_unwrap, "_unwrap", krom_uv_unwrap_unwrap);
  386. SET_FUNCTION(krom_uv_unwrap, "_destroy", krom_uv_unwrap_destroy);
  387. global->Set(String::NewFromUtf8(isolate, "Krom_uv_unwrap").ToLocalChecked(), krom_uv_unwrap);
  388. Local<ObjectTemplate> krom_import_svg = ObjectTemplate::New(isolate);
  389. SET_FUNCTION(krom_import_svg, "_buffer", krom_import_svg_buffer);
  390. SET_FUNCTION(krom_import_svg, "_init", krom_import_svg_init);
  391. SET_FUNCTION(krom_import_svg, "_parse", krom_import_svg_parse);
  392. SET_FUNCTION(krom_import_svg, "_get_pixels_w", krom_import_svg_get_pixels_w);
  393. SET_FUNCTION(krom_import_svg, "_get_pixels_h", krom_import_svg_get_pixels_h);
  394. SET_FUNCTION(krom_import_svg, "_get_pixels", krom_import_svg_get_pixels);
  395. SET_FUNCTION(krom_import_svg, "_destroy", krom_import_svg_destroy);
  396. global->Set(String::NewFromUtf8(isolate, "Krom_import_svg").ToLocalChecked(), krom_import_svg);
  397. Local<ObjectTemplate> krom_import_gltf = ObjectTemplate::New(isolate);
  398. SET_FUNCTION(krom_import_gltf, "_buffer", krom_import_gltf_buffer);
  399. SET_FUNCTION(krom_import_gltf, "_init", krom_import_gltf_init);
  400. SET_FUNCTION(krom_import_gltf, "_parse", krom_import_gltf_parse);
  401. SET_FUNCTION(krom_import_gltf, "_get_vertex_count", krom_import_gltf_get_vertex_count);
  402. SET_FUNCTION(krom_import_gltf, "_get_index_count", krom_import_gltf_get_index_count);
  403. SET_FUNCTION(krom_import_gltf, "_get_indices", krom_import_gltf_get_indices);
  404. SET_FUNCTION(krom_import_gltf, "_get_positions", krom_import_gltf_get_positions);
  405. SET_FUNCTION(krom_import_gltf, "_get_normals", krom_import_gltf_get_normals);
  406. SET_FUNCTION(krom_import_gltf, "_get_uvs", krom_import_gltf_get_uvs);
  407. SET_FUNCTION(krom_import_gltf, "_get_scale_pos", krom_import_gltf_get_scale_pos);
  408. SET_FUNCTION(krom_import_gltf, "_destroy", krom_import_gltf_destroy);
  409. global->Set(String::NewFromUtf8(isolate, "Krom_import_gltf").ToLocalChecked(), krom_import_gltf);
  410. Local<ObjectTemplate> krom_import_usdc = ObjectTemplate::New(isolate);
  411. SET_FUNCTION(krom_import_usdc, "_buffer", krom_import_usdc_buffer);
  412. SET_FUNCTION(krom_import_usdc, "_init", krom_import_usdc_init);
  413. SET_FUNCTION(krom_import_usdc, "_parse", krom_import_usdc_parse);
  414. SET_FUNCTION(krom_import_usdc, "_get_vertex_count", krom_import_usdc_get_vertex_count);
  415. SET_FUNCTION(krom_import_usdc, "_get_index_count", krom_import_usdc_get_index_count);
  416. SET_FUNCTION(krom_import_usdc, "_get_indices", krom_import_usdc_get_indices);
  417. SET_FUNCTION(krom_import_usdc, "_get_positions", krom_import_usdc_get_positions);
  418. SET_FUNCTION(krom_import_usdc, "_get_normals", krom_import_usdc_get_normals);
  419. SET_FUNCTION(krom_import_usdc, "_get_uvs", krom_import_usdc_get_uvs);
  420. SET_FUNCTION(krom_import_usdc, "_get_scale_pos", krom_import_usdc_get_scale_pos);
  421. SET_FUNCTION(krom_import_usdc, "_destroy", krom_import_usdc_destroy);
  422. global->Set(String::NewFromUtf8(isolate, "Krom_import_usdc").ToLocalChecked(), krom_import_usdc);
  423. Local<ObjectTemplate> krom_import_fbx = ObjectTemplate::New(isolate);
  424. SET_FUNCTION(krom_import_fbx, "_buffer", krom_import_fbx_buffer);
  425. SET_FUNCTION(krom_import_fbx, "_init", krom_import_fbx_init);
  426. SET_FUNCTION(krom_import_fbx, "_parse", krom_import_fbx_parse);
  427. SET_FUNCTION(krom_import_fbx, "_get_vertex_count", krom_import_fbx_get_vertex_count);
  428. SET_FUNCTION(krom_import_fbx, "_get_index_count", krom_import_fbx_get_index_count);
  429. SET_FUNCTION(krom_import_fbx, "_get_indices", krom_import_fbx_get_indices);
  430. SET_FUNCTION(krom_import_fbx, "_get_positions", krom_import_fbx_get_positions);
  431. SET_FUNCTION(krom_import_fbx, "_get_normals", krom_import_fbx_get_normals);
  432. SET_FUNCTION(krom_import_fbx, "_get_uvs", krom_import_fbx_get_uvs);
  433. SET_FUNCTION(krom_import_fbx, "_get_colors", krom_import_fbx_get_colors);
  434. SET_FUNCTION(krom_import_fbx, "_get_scale_pos", krom_import_fbx_get_scale_pos);
  435. SET_FUNCTION(krom_import_fbx, "_get_transform", krom_import_fbx_get_transform);
  436. SET_FUNCTION(krom_import_fbx, "_get_name", krom_import_fbx_get_name);
  437. SET_FUNCTION(krom_import_fbx, "_destroy", krom_import_fbx_destroy);
  438. SET_FUNCTION(krom_import_fbx, "_has_next", krom_import_fbx_has_next);
  439. global->Set(String::NewFromUtf8(isolate, "Krom_import_fbx").ToLocalChecked(), krom_import_fbx);
  440. }