BabylonReactNative
BabylonReactNative copied to clipboard
Pixel Scaling
Evaluate state and if we have to do something regarding DPI scaling in Babylon React Native. Related BN issue : https://github.com/BabylonJS/BabylonNative/issues/1016
On Windows: size in OnSizeChanged is logical.
on iOS: MTKView size is in logical coord but its value is multiplied by the content factor here: https://github.com/BabylonJS/BabylonReactNative/blob/7123f41839ac8d0850528ce3f2a26af56b13f74d/Modules/%40babylonjs/react-native-iosandroid/ios/BabylonNativeInterop.mm#L58
It means rendering is done in native resolution. I did a quick try at forcing the contentScaleFactor at 1.0 in EngineViewManager and it properly renders at logical resolution.
Changing contentScaleFactor from the doc:
In general, you should not need to modify the value in this property. However, if your application draws using OpenGL ES, you may want to change the scale factor to trade image quality for rendering performance.
https://developer.apple.com/documentation/uikit/uiview/1622657-contentscalefactor?language=objc
on Android Native window is used to get native size. Rendering is done in native resolution. https://github.com/BabylonJS/BabylonReactNative/blob/7123f41839ac8d0850528ce3f2a26af56b13f74d/Modules/%40babylonjs/react-native-iosandroid/android/src/main/cpp/BabylonNativeInterop.cpp#L69
Related issues in BN : https://github.com/BabylonJS/BabylonNative/issues/1016 https://github.com/BabylonJS/BabylonNative/issues/65