diff --git a/Modules/@babylonjs/react-native-windows/windows/include/XrAnchorHelperOpenXR.h b/Modules/@babylonjs/react-native-windows/windows/include/XrAnchorHelperOpenXR.h new file mode 100644 index 000000000..270d1acf5 --- /dev/null +++ b/Modules/@babylonjs/react-native-windows/windows/include/XrAnchorHelperOpenXR.h @@ -0,0 +1,41 @@ +#pragma once + +#if __has_include("jsi/jsi.h") +#include "jsi/jsi.h" +#include + +namespace BabylonReactNative +{ + bool TryGetNativeAnchor(facebook::jsi::Runtime& jsiRuntime, facebook::jsi::Value& jsAnchor, XrSpatialAnchorMSFT& nativeAnchor) + { + nativeAnchor = nullptr; + if (!jsAnchor.isObject()) + { + return false; + } + + if (!jsiRuntime.global().hasProperty(jsiRuntime, "navigator")) + { + return false; + } + + auto navigator{ jsiRuntime.global().getProperty(jsiRuntime, "navigator").asObject(jsiRuntime) }; + if (!navigator.hasProperty(jsiRuntime, "xr")) + { + return false; + } + + auto nativeXr{ navigator.getProperty(jsiRuntime, "xr").asObject(jsiRuntime) }; + if (!nativeXr.hasProperty(jsiRuntime, "getNativeAnchor")) + { + return false; + } + + auto getNativeAnchor{nativeXr.getPropertyAsFunction(jsiRuntime, "getNativeAnchor")}; + auto nativeAnchorPtr{static_cast(getNativeAnchor.call(jsiRuntime, { jsAnchor.asObject(jsiRuntime) }).asNumber())}; + + nativeAnchor = reinterpret_cast(nativeAnchorPtr); + return true; + } +} +#endif diff --git a/Modules/@babylonjs/react-native/submodules/BabylonNative b/Modules/@babylonjs/react-native/submodules/BabylonNative index 3ecbb47e6..2a7e5394e 160000 --- a/Modules/@babylonjs/react-native/submodules/BabylonNative +++ b/Modules/@babylonjs/react-native/submodules/BabylonNative @@ -1 +1 @@ -Subproject commit 3ecbb47e61124cf5e8464b34d1a7d5f899ff6f3f +Subproject commit 2a7e5394ea6b76dbde80fa6a7aa572b488484e97