Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Modules/@babylonjs/react-native-windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ This package contains windows dependencies for @babylonjs/react-native. See @bab
This package has several **peer dependencies**. If these dependencies are unmet, `npm install` will emit warnings. Be sure to add these dependencies to your project.

This package will not work without installing the `@babylonjs/react-native` peer dependency.
The `react-native-permissions` dependency is required for XR capabilities of Babylon.js.

### Universal Windows Platform (UWP) Configuration

The minimum UWP target platform version is 10.0.18362.0. UWP BabylonReactNative requires the following NPM dependencies. These versions contradict the peer dependencies declared in package.json in order to support Android and iOS consumers using older versions of react and react-native.
The `react-native-permissions` dependency is required for XR capabilities of Babylon.js.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Note: CppWinRT NuGet dependency should be resolved for the solution not the individual project -->
<Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.props')" />
<Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
Expand Down Expand Up @@ -80,6 +80,7 @@
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<GenerateManifest>false</GenerateManifest>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
Expand Down Expand Up @@ -318,13 +319,13 @@
<Error Condition="!Exists('$(BabylonNativeBuildDir)') And !Exists('$(BabylonNativeLibsDir)')" Text="$(ErrorText)" />
</Target>
<ImportGroup Label="ExtensionTargets">
<Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', $(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', $(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<Midl Include="EngineView.idl" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="BabylonReactNative.def" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.201102.2" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.210122.3" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#pragma once

#ifndef NOMINMAX
#define NOMINMAX
#endif

#ifndef WINRT_LEAN_AND_MEAN
#define WINRT_LEAN_AND_MEAN
#endif

#include <unknwn.h>
#include <winrt/Windows.Devices.Input.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#if __has_include("jsi/jsi.h")
#include "jsi/jsi.h"
#include "IXrContextOpenXR.h"

namespace BabylonReactNative
{
bool TryGetXrContext(facebook::jsi::Runtime& jsiRuntime, const facebook::jsi::Value& xrSession, IXrContextOpenXR*& xrContext)
{
xrContext = nullptr;
if (!xrSession.isObject() ||
!xrSession.asObject(jsiRuntime).hasProperty(jsiRuntime, "nativeXrContext") ||
!xrSession.asObject(jsiRuntime).hasProperty(jsiRuntime, "nativeXrContextType") ||
xrSession.asObject(jsiRuntime).getProperty(jsiRuntime, "nativeXrContextType").asString(jsiRuntime).utf8(jsiRuntime) != "OpenXR")
{
return false;
}

auto nativeExtensionPtr = static_cast<uintptr_t>(xrSession.asObject(jsiRuntime).getProperty(jsiRuntime, "nativeXrContext").asNumber());
xrContext = reinterpret_cast<IXrContextOpenXR*>(nativeExtensionPtr);
return true;
}
}
#endif
33 changes: 31 additions & 2 deletions Package/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ const createUWPDirectories = async () => {
shelljs.mkdir('-p', 'Assembled-Windows/windows/libs/x64/Debug');
shelljs.mkdir('-p', 'Assembled-Windows/windows/libs/x64/Release');
shelljs.mkdir('-p', 'Assembled-Windows/windows/BabylonReactNative');
shelljs.mkdir('-p', 'Assembled-Windows/windows/include');
shelljs.mkdir('-p', 'Assembled-Windows/windows/OpenXR-MixedReality/include/openxr');
shelljs.mkdir('-p', 'Assembled-Windows/windows/OpenXR-MixedReality/include/XrUtility');
}

const copyCommonFilesUWP = () => {
Expand Down Expand Up @@ -301,6 +304,28 @@ const copyVCXProjUWPFiles = () => {
.pipe(gulp.dest('Assembled-Windows/windows/BabylonReactNative'));
}

const copyOpenXRInfoFiles = () => {
return gulp.src('../Modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/xr/Dependencies/OpenXR-MixedReality/LICENSE')
.pipe(gulp.src('../Modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/xr/Dependencies/OpenXR-MixedReality/README.md'))
.pipe(gulp.dest('Assembled-Windows/windows/OpenXR-MixedReality'));
}

const copyOpenXRPreviewHeaders = () => {
return gulp.src('../Modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/xr/Dependencies/OpenXR-MixedReality/openxr_preview/include/openxr/*')
.pipe(gulp.dest('Assembled-Windows/windows/OpenXR-MixedReality/include/openxr'));
}

const copyOpenXRUtilityHeaders = () => {
return gulp.src('../Modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/xr/Dependencies/OpenXR-MixedReality/shared/XrUtility/*')
.pipe(gulp.dest('Assembled-Windows/windows/OpenXR-MixedReality/include/XrUtility'));
}

const copyOpenXRHelperHeaders = () => {
return gulp.src('../Modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/xr/Source/OpenXR/Include/*')
.pipe(gulp.src('../Modules/@babylonjs/react-native-windows/windows/include/*'))
.pipe(gulp.dest('Assembled-Windows/windows/include'));
}

const copyUWPFiles = gulp.series(
createUWPDirectories,
gulp.parallel(
Expand All @@ -313,7 +338,11 @@ const copyUWPFiles = gulp.series(
copyARMReleaseUWPFiles,
copyARM64DebugUWPFiles,
copyARM64ReleaseUWPFiles,
copyVCXProjUWPFiles));
copyVCXProjUWPFiles,
copyOpenXRInfoFiles,
copyOpenXRPreviewHeaders,
copyOpenXRUtilityHeaders,
copyOpenXRHelperHeaders));

const validate = async () => {
// When the package contents are updated *and validated*, update the expected below by running 'find Assembled | pbcopy' and pasting it over the expected string.
Expand Down Expand Up @@ -470,4 +499,4 @@ exports.copyUWPFiles = copyUWPFiles;
exports.packUWP = packUWP;
exports.packUWPNoBuild = packUWPNoBuild;

exports.default = build;
exports.default = build;
Loading