Skip to content

Use BabylonNative WindowT type#708

Draft
CedricGuillemet wants to merge 2 commits intoBabylonJS:masterfrom
CedricGuillemet:UpdateViewLayer
Draft

Use BabylonNative WindowT type#708
CedricGuillemet wants to merge 2 commits intoBabylonJS:masterfrom
CedricGuillemet:UpdateViewLayer

Conversation

@CedricGuillemet
Copy link
Collaborator

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the React Native Babylon Native interop to pass a platform-specific graphics “window” handle (Babylon::Graphics::WindowT) into the shared graphics configuration, aligning iOS to pass the Metal layer instead of the MTKView.

Changes:

  • Change BabylonNative::UpdateView declaration to take Babylon::Graphics::WindowT instead of WindowType.
  • Update shared ReactNativeModule::UpdateView to store the passed WindowT directly (removing the iOS-only window.layer conversion).
  • Update iOS interop to call UpdateView with mtkView.layer.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
Modules/@babylonjs/react-native/shared/BabylonNative.h Changes the UpdateView API to accept Babylon::Graphics::WindowT.
Modules/@babylonjs/react-native/shared/BabylonNative.cpp Updates internal UpdateView to store the window handle directly, removing iOS conditional logic.
Modules/@babylonjs/react-native/ios/BabylonNativeInterop.mm Passes mtkView.layer into UpdateView on iOS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

void Deinitialize();

void UpdateView(WindowType window, size_t width, size_t height);
void UpdateView(Babylon::Graphics::WindowT window, size_t width, size_t height);
Comment on lines +84 to 89
void UpdateView(Babylon::Graphics::WindowT window, size_t width, size_t height)
{
#if defined(__APPLE__)
m_graphicsConfig.Window = (Babylon::Graphics::WindowT)window.layer;
#else
m_graphicsConfig.Window = window;
#endif
m_graphicsConfig.Width = width;
m_graphicsConfig.Height = height;
UpdateGraphicsConfiguration();
const int height = static_cast<int>(mtkView.bounds.size.height * scale);
if (width != 0 && height != 0) {
BabylonNative::UpdateView(mtkView, width, height);
BabylonNative::UpdateView(mtkView.layer, width, height);
@CedricGuillemet CedricGuillemet marked this pull request as draft March 19, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants