Welcome! Babylon Native is a collection of technologies intended to bring the power and flexibility of Babylon.js to cross-platform applications beyond the browser. The goal of this project is to allow the same JavaScript that powers Babylon.js apps on the Web to work identically in native apps on Windows, Android, macOS, and iOS.
Check out the project's announcement and home page for more information.
NOTE: This project is under heavy development and not all platforms/features are currently available. Please refer to the sections below for details.
Babylon Native is currently available as a public preview. Many features are currently available, and additional features are being added regularly, but certain features are currently unstable or not yet implemented.
The following major features are currently supported and expected to work. Note that this list is not exhaustive.
- Developing Babylon Native on the following platforms: Windows 10, macOS.
- Building and running the libraries and demo apps for the following platforms: Win32, UWP, macOS, iOS.
- Loading and executing JavaScript code on all supported platforms.
- Loading and rendering glTF objects on all supported platforms.
- Network requests (including accessing local files using the
file://
protocol) made throught the Babylon.js APIs. - Extending JavaScript functionality using N-API and native plugins.
The following major features are partially implemented but not yet supported. Note that this list is not exhaustive.
- Developing Babylon Native on the following platforms: Linux.
- Building and running the libraries and demo apps for the following platforms: Android.
- Mixed reality powered by OpenXR on the following platforms: Win32, UWP.
The following major features are not yet supported or implemented, even as previews, but are expected to be supported in the future. Note that this list is not exhaustive.
- Debugging JavaScript with V8.
- User input.
- Font rendering.
- Sub-window, multi-window, and out-of-process rendering.
- React Native integration.
This section will be updated frequently. If you have any questions, please reach out to us on the Babylon forum.
This quick overview will help you get started developing in the Babylon Native repository. We support development on Windows and macOS. (It is also possible, though not yet fully supported, to develop on Linux.) This overview is intended for reasonably experienced developers familiar with common native development principles.
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/BabylonNative.git
Babylon Native makes extensive use of submodules to supply its dependencies, so it's also necessary to set up the submodules.
cd BabylonNative
git submodule update --init --recursive
Babylon Native's build system is based on CMake, which customarily uses a separate
build directory. Build directory location is up to you, but we recommend just creating
a Build
directory within your clone of the Babylon Native repository (Babylon
Native's .gitignore
file is already set up to ignore this Build
directory).
mkdir Build
cd Build
Required Tools: Visual Studio 2019 with C++ development tools, Python 3.0 or newer (required by dependencies)
For Windows development, CMake will generate a Visual Studio Solution. From a
terminal with access to CMake located in your BabylonNative/Build
directory, type
the following (amend paths for alternative build directories):
cmake ..
Note that, by default, this will target the same processor architecture that is being
used to build the solution; so if your developer computer has 64-bit CPU, CMake's
generated solution will target 64-bit CPUs by default. To manually target specific
architectures, tell CMake the intended architecture using the -A
flag, as shown below.
Supported arguments for using this flag with Babylon Native include Win32
for 32-bit
processors and x64
for 64-bit processors.
cmake -A Win32 ..
CMake will generate a new BabylonNative.sln
file in your working directory. Please
be patient; this process can take several minutes. When the process is completed,
open BabylonNative.sln
by double-clicking on it in Windows Explorer or by entering
the following command:
start BabylonNative.sln
By default, the "Playground" demo app should be set as the Visual Studio start-up
project. Build and run this app by pressing the green "Play" button or by pressing
F5
on your keyboard.
Required Tools: Visual Studio 2019 with C++ and UWP development tools, Python 3.0 or newer (required by dependencies)
For Windows development, CMake will generate a Visual Studio Solution. By default it
will target Win32, so to target UWP (which CMake describes as "Windows Store") you have
to specify certain CMake variables. From a terminal with access to CMake located in
your BabylonNative/Build
directory, type the following (amend paths for alternative
build directories):
cmake -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 ..
Note that, by default, this will target the same processor architecture that is being
used to build the solution; so if your developer computer has 64-bit CPU, CMake's
generated solution will target 64-bit CPUs by default. To manually target specific
architectures, tell CMake the intended architecture using the -A
flag, as shown below.
Supported arguments for using this flag with Babylon Native include Win32
for 32-bit
processors, x64
for 64-bit processors, arm
for ARM processors, and arm64
for
ARM64 processors.
cmake -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 -A arm64 ..
CMake will generate a new BabylonNative.sln
file in your working directory. Please
be patient; this process can take several minutes. When the process is completed,
open BabylonNative.sln
by double-clicking on it in Windows Explorer or by entering
the following command:
start BabylonNative.sln
By default, the "Playground" demo app should be set as the Visual Studio start-up
project. Build and run this app by pressing the green "Play" button or by pressing
F5
on your keyboard.
Required Tools: Xcode 11 or newer, Python 3.0 or newer (required by dependencies)
For macOS development, CMake by default will generate a Makefile. It may be possible to build Babylon Native for macOS using this approach, but at present only the Xcode method is supported. To generate an Xcode project using CMake, you must specify the correct build system generator for CMake to use, as follows:
cmake -G Xcode ..
CMake will generate a new BabylonNative.xcodeproj
file in your working directory.
Please be patient; this process can take several minutes. When the process is
completed, open the project by double-clicking on it in Finder or by entering the
following command:
open BabylonNative.xcodeproj
To select which project to build with Xcode, select the correct project name in the menu to the right of the greyed-out "Stop" button adjacent to the "Play" button in the top-left corner of the Xcode window. For example, to build and run the Playground demo app, click on the project selector and find "Playground" in the list of possible selections. The "Play" button will subsequently allow you to build, run, and debug the selected Babylon Native demo app.
Required Tools: Xcode 11 or newer, Python 3.0 or newer (required by dependencies)
For macOS development, CMake by default will generate a Makefile. It may be possible to build Babylon Native for macOS using this approach, but at present only the Xcode method is supported. To generate an Xcode project using CMake, you must specify the correct build system generator for CMake to use. Additionally, you must tell CMake what toolchain to use, which provides additional information about how to generate an iOS Xcode project correctly. Furthermore, a number of capabilities within Babylon Native's dependencies must be deactivated in order for the project to build correctly; these capabilities are set to their correct state by the additional CMake variables in the following command:
cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=../Dependencies/ios-cmake/ios.toolchain.cmake -DPLATFORM=OS64COMBINED -DENABLE_ARC=0 -DDEPLOYMENT_TARGET=12 -DHTTP_ONLY=OFF -DCMAKE_USE_OPENSSL=OFF -DBUILD_CURL_EXE=OFF -DBUILD_CURL_TESTS=OFF -DCURL_STATICLIB=ON -DUSE_UNIX_SOCKETS=0 -DHAVE_FSETXATTR=0 -DHAVE_LIBSOCKET=0 -DCURL_DISABLE_FTP=OFF -DCURL_DISABLE_LDAP=ON -DCURL_DISABLE_TELNET=ON -DCURL_DISABLE_DICT=ON -DCURL_DISABLE_TFTP=ON -DCURL_DISABLE_IMAP=ON -DCURL_DISABLE_POP3=ON -DCURL_DISABLE_SMTP=ON -DENABLE_GLSLANG_BINARIES=OFF -DSPIRV_CROSS_CLI=OFF -DHAVE_LIBIDN2=OFF ..
CMake will generate a new BabylonNative.xcodeproj
file in your working directory.
Please be patient; this process can take several minutes. When the process is
completed, open the project by double-clicking on it in Finder or by entering the
following command:
open BabylonNative.xcodeproj
To select which project to build with Xcode, select the correct project name in the menu to the right of the greyed-out "Stop" button adjacent to the "Play" button in the top-left corner of the Xcode window. For example, to build and run the Playground demo app, click on the project selector and find "Playground" in the list of possible selections. The "Play" button will subsequently allow you to build, run, and debug the selected Babylon Native demo app.
In order to compile the WebGL GLSL shader to the required bits for the target platform, this project utilizes glslang and SPIRV-Cross. See ShaderCompiler.h and its corresponding implementation for details.
This project makes substantial use of the utilities contained within the arcana.cpp project, especially the support for asynchronous task execution and thread synchronization.
This project uses a subset of node-addon-api and the JavaScript part of N-API to target either V8 or Chakra. See this thread for some context. There is also work needed to factor out the JavaScript part of node-addon-api.
The code is located here. Some small modifications were made to avoid node dependencies and improve performance. The Chakra version js_native_api_chakra.cc came from node_api_jsrt.cc and was modified to target Chakra directly. We will work on submitting these changes to the public version.
This project uses bgfx for the cross-platform rendering abstraction. It does not use the shader abstraction of bgfx, but instead compiles the WebGL GLSL shader at runtime and generates the shader header that bgfx expects. See NativeEngine.cpp for implementation details.
This project uses base-n to implement base64 decoding for parsing data URLs.
This project uses curl (or, more accurately, libcurl) as the backend for the provided implementation of XMLHttpRequest. At present, only a "golden path" is supported, but additional features will be added as they are required.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.
Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) at secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.