BabylonReactNative icon indicating copy to clipboard operation
BabylonReactNative copied to clipboard

macOS Desktop Apps

Open keverw opened this issue 4 years ago • 8 comments

I noticed there's iOS, Android and Windows mentioned. Wonder if macOS desktop apps could be supported too in the future? Seems Babylon native itself wants to support Mac, so not sure if the React Native wrapper around it could do the same, I haven't attempted to try it yet though.

keverw avatar Apr 11 '21 23:04 keverw

Since Babylon Native supports MacOS, and React Native supports MacOS, I expect Babylon React Native could support MacOS pretty easily, it's just not something we've attempted at this point either. If you'd like to take a stab at it, we could certainly point you in the right direction!

ryantrem avatar Apr 12 '21 00:04 ryantrem

These are the main files that do the integration for iOS, so it should be very similar for MacOS: https://github.com/BabylonJS/BabylonReactNative/tree/master/Modules/%40babylonjs/react-native/ios

ryantrem avatar Apr 12 '21 00:04 ryantrem

Thanks. I'm not that far along with on my own project. I haven't really worked with much native development with XCode but at least some pointers!

I'm thinking maybe mostly a copy/paste and maybe changing https://github.com/BabylonJS/BabylonReactNative/blob/master/Modules/%40babylonjs/react-native/ios/EngineViewManager.mm since UIKit isn't for Mac unless a catalyst app. I forget where, i read HN sometimes way too much and thought I was reading something before about someone who maintained both a Mac and iOS app with common shared code. I guess it's AppKit instead. https://stackoverflow.com/a/51517616

keverw avatar Apr 12 '21 00:04 keverw

Yea that's right, the MacOS version of EngineViewManager.mm would use the MacOS (AppKit?) MTKView. You can see how this was done in the Babylon Native Playground app (it has more code because there is less shared code across the platforms in the Playground app): https://github.com/BabylonJS/BabylonNative/blob/master/Apps/Playground/macOS/ViewController.mm

I hope that BabylonNativeInterop.mm is very similar to iOS, but I haven't worked with React Native for MacOS yet, so I'm not sure if the JSI runtime and CallInvoker are accessed the same as for iOS.

ryantrem avatar Apr 12 '21 00:04 ryantrem

Someone on the forum is trying to do the work : https://forum.babylonjs.com/t/im-trying-to-make-babylonreactnative-to-work-on-macos/39178/74

CedricGuillemet avatar May 26 '23 09:05 CedricGuillemet

@keverw Do you have to use XR functionality? I've ported without XR, since XR functionality requires react-native-permissions, which does not supports macOS.

For more info about it, check for my blog: https://medium.com/@jihoobyeon/babylon-js-at-react-native-for-macos-779f7680a6d6

jihoobyeon avatar Jul 24 '23 11:07 jihoobyeon

@jihoobyeon very cool! Sorry to hear it was harder to get working than we hoped, but I'm glad you got it! I would not say what you have done is incomplete due to the lack of XR support though as MacOS has no underlying platform level support for XR (e.g. ARKit doesn't exist on MacOS). Would you consider contributing your MacOS support back to the Babylon React Native repo?

ryantrem avatar Jul 25 '23 02:07 ryantrem

@ryantrem Yes, I'd love to! but since I've modified some of shared files (e. g. Modules/@babylonjs/react-native/shared/BabylonNative.cpp), so direct merge would cause crash for other OSes. I will add some lines of code to check OS is macOS or not, and little cleanups. I'll make a merge request after then.

jihoobyeon avatar Jul 25 '23 09:07 jihoobyeon

macOS is supported by RNTA : https://github.com/BabylonJS/BabylonReactNative/pull/641 Once that PR is in, we can talk about https://github.com/BabylonJS/BabylonReactNative/pull/593 , update it and do a proper CI build. Closing for now.

CedricGuillemet avatar Apr 18 '24 09:04 CedricGuillemet