Open lukelento06 opened 8 months ago
Second potential solution, turns out there is documentation in Swift for communicating with JS files.
This blog explains how it can be used in code https://davidchuprogramming.blogspot.com/2022/08/build-bridge-between-swift-and-js.html
WKScriptMessageHandler could be used for this issue, heres the doc for it https://developer.apple.com/documentation/webkit/wkscriptmessagehandler
The following question/answer on stack overflow actually gives a good example of how WKScriptMessageHandler is used https://stackoverflow.com/questions/65270083/how-does-the-ios-14-api-wkscriptmessagehandlerwithreply-work-for-communicating-w
For loading levels, we need to be able to access the levels folder and its children through the website's JavaScript file. A possible solution could be to use a JSON file somewhere to hard-code the base levels in and append any user generated levels upon the user's input, but finding a way to automate this further would be preferred.
Adding on, as we are not in a Node.js environment, our website JS cannot access files using fs or any other Node.js module. This means we have to find a way to incorporate the swift level files and the JavaScript website files and make them meet each other halfway for loading and presenting levels in Babylon.