Skip to content

Commit e93f7b8

Browse files
committed
fix: android implementation
1 parent f69e13a commit e93f7b8

File tree

9 files changed

+3232
-10659
lines changed

9 files changed

+3232
-10659
lines changed

Diff for: Apps/BRNPlayground/android/gradle.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
4040
# to write custom TurboModules/Fabric components OR use libraries that
4141
# are providing them.
4242
# Note that this is incompatible with web debugging.
43-
newArchEnabled=false
43+
newArchEnabled=true
4444
hermesEnabled=true
45+
bridgelessEnabled=true
4546

4647
# Uncomment the line below if building react-native from source
4748
#ANDROID_NDK_VERSION=26.1.10909125

Diff for: Apps/BRNPlayground/package-lock.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Apps/BRNPlayground/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@babylonjs/react-native": "file:../../Modules/@babylonjs/react-native",
2323
"@babylonjs/react-native-iosandroid": "file:../../Modules/@babylonjs/react-native-iosandroid",
2424
"@babylonjs/react-native-windows": "file:../../Modules/@babylonjs/react-native-windows",
25-
"@react-native-community/slider": "^4.2.2",
25+
"@react-native-community/slider": "^4.5.5",
2626
"react": "18.2.0",
2727
"react-native": "0.73.5",
2828
"react-native-macos": "^0.73.0",

Diff for: Modules/@babylonjs/react-native-iosandroid/android/src/fabric/java/com/babylonreactnative/BabylonModule.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
@ReactModule(name = BabylonModule.NAME)
1010
public final class BabylonModule extends NativeBabylonModuleSpec {
11-
static final String NAME = "EngineViewNativeComponent";
11+
static final String NAME = "BabylonModule";
1212

1313
BabylonModule(ReactApplicationContext reactContext) {
1414
super(reactContext);
@@ -17,22 +17,22 @@ public final class BabylonModule extends NativeBabylonModuleSpec {
1717
@NonNull
1818
@Override
1919
public String getName() {
20-
return BabylonModule.NAME;
20+
return BabylonModule.NAME;
2121
}
2222

2323
@Override
2424
public void initialize(Promise promise) {
25-
// this.getReactApplicationContext().runOnJSQueueThread(() -> {
26-
// BabylonNativeInterop.initialize(this.getReactApplicationContext());
27-
// promise.resolve(null);
28-
// });
25+
this.getReactApplicationContext().runOnJSQueueThread(() -> {
26+
BabylonNativeInterop.initialize(this.getReactApplicationContext());
27+
promise.resolve(null);
28+
});
2929
}
3030

3131
@Override
3232
public void resetView(Promise promise) {
33-
// this.getReactApplicationContext().runOnUiQueueThread(() -> {
34-
// BabylonNativeInterop.resetView();
35-
// promise.resolve(null);
36-
// });
33+
this.getReactApplicationContext().runOnUiQueueThread(() -> {
34+
BabylonNativeInterop.resetView();
35+
promise.resolve(null);
36+
});
3737
}
3838
}

Diff for: Modules/@babylonjs/react-native-iosandroid/android/src/fabric/java/com/babylonreactnative/EngineViewManager.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package com.babylonreactnative;
22

3-
import android.view.View;
4-
53
import androidx.annotation.NonNull;
64
import androidx.annotation.Nullable;
75

8-
import com.facebook.react.bridge.ReactApplicationContext;
96
import com.facebook.react.module.annotations.ReactModule;
107
import com.facebook.react.uimanager.SimpleViewManager;
118
import com.facebook.react.uimanager.ThemedReactContext;
@@ -40,11 +37,11 @@ protected EngineView createViewInstance(@NonNull ThemedReactContext reactContext
4037
return new EngineView(reactContext);
4138
}
4239

43-
// @Override
44-
// public void onDropViewInstance(@NonNull EngineView view) {
45-
// super.onDropViewInstance(view);
46-
// // TODO: Native view specific cleanup
47-
// }
40+
@Override
41+
public void onDropViewInstance(@NonNull EngineView view) {
42+
super.onDropViewInstance(view);
43+
// TODO: Native view specific cleanup
44+
}
4845

4946
@Override
5047
public void setIsTransparent(EngineView view, boolean value) {
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
package com.babylonreactnative;
22

33
import androidx.annotation.NonNull;
4-
import androidx.annotation.Nullable;
54

65
import java.util.Arrays;
7-
import java.util.HashMap;
86
import java.util.List;
9-
import java.util.Map;
107

11-
import com.facebook.react.BaseReactPackage;
128
import com.facebook.react.ReactPackage;
13-
import com.facebook.react.TurboReactPackage;
149
import com.facebook.react.bridge.NativeModule;
1510
import com.facebook.react.bridge.ReactApplicationContext;
16-
import com.facebook.react.module.model.ReactModuleInfo;
17-
import com.facebook.react.module.model.ReactModuleInfoProvider;
1811
import com.facebook.react.uimanager.ViewManager;
1912

2013
public class BabylonPackage implements ReactPackage {
@@ -27,6 +20,8 @@ public List<NativeModule> createNativeModules(ReactApplicationContext reactConte
2720
@NonNull
2821
@Override
2922
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
23+
// We have two implementations of EngineViewManager, one per architecture.
24+
// Implementation source code is determined by the sourceSets in the build.gradle file.
3025
return Arrays.<ViewManager>asList(new EngineViewManager());
3126
}
3227
}

Diff for: Modules/@babylonjs/react-native/EngineView.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface EngineViewProps extends NativeEngineViewProps {
99
camera?: Camera;
1010
displayFrameRate?: boolean;
1111
isTransparent?: boolean;
12+
androidView?: "TextureView" | "SurfaceView" | "SurfaceViewZTopMost" | "SurfaceViewZMediaOverlay";
1213
antiAliasing?: 0 | 1 | 2 | 4 | 8 | 16;
1314
onInitialized?: (view: EngineViewCallbacks) => void;
1415
}

0 commit comments

Comments
 (0)