diff --git a/Modules/@babylonjs/react-native/shared/XrAnchorHelper.h b/Modules/@babylonjs/react-native/shared/XrAnchorHelper.h index 9c35a89f5..ad4672b06 100644 --- a/Modules/@babylonjs/react-native/shared/XrAnchorHelper.h +++ b/Modules/@babylonjs/react-native/shared/XrAnchorHelper.h @@ -183,3 +183,47 @@ namespace Babylon::Plugins::NativeXr } #endif #endif + +#if __has_include("IXrContextARKit.h") +#include "IXrContextARKit.h" +#if __has_include("jsi/jsi.h") +namespace Babylon::Plugins::NativeXr +{ + bool TryGetNativeAnchor(facebook::jsi::Runtime& jsiRuntime, facebook::jsi::Value& jsAnchor, ARAnchor*& nativeAnchor) + { + nativeAnchor = nullptr; + uintptr_t nativeAnchorPtr{reinterpret_cast(nullptr)}; + if (TryGetNativeAnchor(jsiRuntime, jsAnchor, nativeAnchorPtr)) + { + nativeAnchor = reinterpret_cast(nativeAnchorPtr); + return true; + } + + return false; + } +} +#endif +#if __has_include("napi/env.h") +namespace Babylon::Plugins::NativeXr +{ + bool TryGetNativeAnchor(Napi::Env env, Napi::Value anchor, ARAnchor*& nativeAnchor) + { + nativeAnchor = nullptr; + uintptr_t nativeAnchorPtr{reinterpret_cast(nullptr)}; + if (TryGetNativeAnchor(env, anchor, nativeAnchorPtr)) + { + nativeAnchor = reinterpret_cast(nativeAnchorPtr); + return true; + } + + return false; + } + + bool TryDeclareNativeAnchor(Napi::Env env, const Napi::Value& session, ARAnchor* nativeAnchor, Napi::Value& xrAnchor) + { + uintptr_t nativeAnchorPtr{reinterpret_cast(nativeAnchor)}; + return TryDeclareNativeAnchor(env, session, nativeAnchorPtr, xrAnchor); + } +} +#endif +#endif diff --git a/Modules/@babylonjs/react-native/shared/XrContextHelper.h b/Modules/@babylonjs/react-native/shared/XrContextHelper.h index 2e18d0cae..963cae421 100644 --- a/Modules/@babylonjs/react-native/shared/XrContextHelper.h +++ b/Modules/@babylonjs/react-native/shared/XrContextHelper.h @@ -139,3 +139,41 @@ namespace Babylon::Plugins::NativeXr } #endif #endif + +#if __has_include("IXrContextARKit.h") +#include "IXrContextARKit.h" +#if __has_include("jsi/jsi.h") +namespace Babylon::Plugins::NativeXr +{ + bool TryGetXrContext(facebook::jsi::Runtime& jsiRuntime, IXrContextARKit*& xrContext) + { + xrContext = nullptr; + uintptr_t nativePtr{reinterpret_cast(nullptr)}; + if (TryGetXrContext(jsiRuntime, "ARKit", nativePtr)) + { + xrContext = reinterpret_cast(nativePtr); + return true; + } + + return false; + } +} +#endif +#if __has_include("napi/env.h") +namespace Babylon::Plugins::NativeXr +{ + bool TryGetXrContext(Napi::Env env, IXrContextARKit*& xrContext) + { + xrContext = nullptr; + uintptr_t nativePtr{reinterpret_cast(nullptr)}; + if (TryGetXrContext(env, "ARKit", nativePtr)) + { + xrContext = reinterpret_cast(nativePtr); + return true; + } + + return false; + } +} +#endif +#endif diff --git a/Modules/@babylonjs/react-native/submodules/BabylonNative b/Modules/@babylonjs/react-native/submodules/BabylonNative index dd9e316dc..4de24f77a 160000 --- a/Modules/@babylonjs/react-native/submodules/BabylonNative +++ b/Modules/@babylonjs/react-native/submodules/BabylonNative @@ -1 +1 @@ -Subproject commit dd9e316dc6f3396f9ee045a5a565095381e53ad6 +Subproject commit 4de24f77ad090e0c7773c20b40b89e3a55730a8b