Use BabylonNative WindowT type#708
Draft
CedricGuillemet wants to merge 2 commits intoBabylonJS:masterfrom
Draft
Conversation
There was a problem hiding this comment.
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::UpdateViewdeclaration to takeBabylon::Graphics::WindowTinstead ofWindowType. - Update shared
ReactNativeModule::UpdateViewto store the passedWindowTdirectly (removing the iOS-onlywindow.layerconversion). - Update iOS interop to call
UpdateViewwithmtkView.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); |
bghgary
approved these changes
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.