i have already have a bevy app that run in the browser.
what i want to do is having some function in the js/ts side that can create or destory a entity in the bevy world, can this be possible? I have try to let app=App::new();
, then bind a function to run app app.run();
, and bind a function to override resource app.insert_resource(...);
. but when i call the function to override resource after run app, it show error with message: recursive use of an object detected which would lead to unsafe aliasing in rust.
thanks for @kmdreko 's advice, i try to use Arc to update resrouce, but it seems having another problem before this,the problem is after i init the bevy app, the rest code will never reach, there is my code:
<script type="module">
import init, {BevyApp} from '../pkg/wasm_bevy_demo.js';
init().then(() => {
// new() function create and run a bevy app, and return a Arc<Mutex> in BevyApp{}
const bevyCode = BevyApp.new();
// this log info never show in the console
console.log("reach after run bevy app");
bevyCode.update_scroll_rate(10, 10);
})
</script>