This project provides Babylon Native integration into React Native.
Babylon React Native is in the early phase of its development, and has the following limitations:
- Android support only - support for both iOS and Windows is planned.
- JavaScriptCore only - support for Hermes is planned, and support for other JavaScript engines used by React Native is uncertain.
See the package usage or the Playground app's App.tsx for example usage.
This quick overview will help you get started developing in the Babylon React Native repository. We support development on Windows and macOS, but assume the use of PowerShell in the instructions below.
Step 1 for all development environments and targets is to clone the repo. Use a git-enabled terminal to follow the steps below.
git clone https://github.com/BabylonJS/BabylonReactNative
Babylon React Native makes extensive use of submodules to supply its dependencies, so it's also necessary to set up the submodules.
cd BabylonReactNative
git submodule update --init --recursive
The Playground sample/test app is a standard React Native app, and as such also makes extensive use of NPM packages to supply its dependencies, so it's also necessary to install these packages.
cd Apps/Playground
yarn install
Required Tools: Android Studio (including NDK 21.0.6113669), CMake, Ninja
- The
PATH
environment variable must include the path to adb (typically ~/Library/Android/sdk/platform-tools/). - The
PATH
environment variable must include the path to Ninja, or Ninja must be installed via a package manager. - The
ANDROID_HOME
environment variable must be defined (typically ~/Library/Android/sdk). - The
ANDROID_SDK_ROOT
environment variable must be defined (typically ~/Library/Android/sdk). - The
ANDROID_AVD_HOME
environment variable must be defined if you plan to use Android emulators (typically ~/.android/avd).
You can typically configure your environment by editing ~/.zshrc
and adding the following:
export PATH=$PATH:~/Library/Android/sdk/platform-tools/
export PATH=$PATH:~/path_to_ninja_binary/ # Only for manual installations of Ninja (not package manager-based installations).
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export ANDROID_AVD_HOME=~/.android/avd
Required Tools: Android Studio (including NDK 21.0.6113669), CMake, Ninja
- The
PATH
environment variable must include the path to adb (typically %LOCALAPPDATA%/Android/sdk/platform-tools/). - The
PATH
environment variable must include the path to Ninja, or Ninja must be installed via a package manager. - The
ANDROID_HOME
environment variable must be defined (typically %LOCALAPPDATA%/Android/sdk). - The
JAVA_HOME
environment variable must be defined (typically %ProgramFiles%/Android/Android Studio/jre).
On either Mac or Windows, NPX is used to build and run the Playground sample/test app from the command line. Open a command prompt at the root of the BabylonReactNative repo if you don't have one already open.
cd Apps/Playground
npx react-native run-android
After having run the above command, you can also open Apps/Playground/android
in Android Studio and run the app from there.
If you want to test using a local build of the NPM package with your own React Native app, you can do so with the npm pack
command on either Mac or Windows.
cd Apps/Playground/node_modules/react-native-babylon
npm pack
This will produce a zipped local NPM package that can be installed into a React Native application for testing purposes.