@babylonjs/react-native 0.4.0-alpha.4 → 0.4.0-alpha.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/BabylonModule.d.ts +2 -0
  2. package/BabylonModule.js +21 -0
  3. package/BabylonModule.js.map +1 -0
  4. package/EngineHook.d.ts +3 -0
  5. package/EngineHook.js +179 -0
  6. package/EngineHook.js.map +1 -0
  7. package/EngineView.d.ts +12 -0
  8. package/EngineView.js +117 -0
  9. package/EngineView.js.map +1 -0
  10. package/FontFace.d.ts +12 -0
  11. package/FontFace.js +35 -0
  12. package/FontFace.js.map +1 -0
  13. package/NativeCapture.d.ts +14 -0
  14. package/NativeCapture.js +14 -0
  15. package/NativeCapture.js.map +1 -0
  16. package/README.md +2 -6
  17. package/ReactNativeEngine.d.ts +7 -0
  18. package/ReactNativeEngine.js +33 -0
  19. package/ReactNativeEngine.js.map +1 -0
  20. package/VersionValidation.d.ts +1 -0
  21. package/VersionValidation.js +13 -0
  22. package/VersionValidation.js.map +1 -0
  23. package/android/build.gradle +13 -1
  24. package/android/include/IXrContextARCore.h +10 -0
  25. package/android/src/main/java/com/babylonreactnative/BabylonModule.java +7 -20
  26. package/android/src/main/java/com/babylonreactnative/BabylonNativeInterop.java +89 -140
  27. package/android/src/main/java/com/babylonreactnative/EngineView.java +60 -11
  28. package/android/src/main/jniLibs/arm64-v8a/libBabylonNative.so +0 -0
  29. package/android/src/main/jniLibs/arm64-v8a/libturbomodulejsijni.so +0 -0
  30. package/android/src/main/jniLibs/armeabi-v7a/libBabylonNative.so +0 -0
  31. package/android/src/main/jniLibs/armeabi-v7a/libturbomodulejsijni.so +0 -0
  32. package/android/src/main/jniLibs/x86/libBabylonNative.so +0 -0
  33. package/android/src/main/jniLibs/x86/libturbomodulejsijni.so +0 -0
  34. package/index.d.ts +4 -0
  35. package/index.js +5 -0
  36. package/index.js.map +1 -0
  37. package/ios/BabylonModule.mm +7 -8
  38. package/ios/BabylonNativeInterop.h +7 -4
  39. package/ios/BabylonNativeInterop.mm +84 -124
  40. package/ios/EngineViewManager.mm +34 -19
  41. package/ios/ReactNativeBabylon.xcodeproj/project.pbxproj +9810 -8605
  42. package/ios/include/IXrContextARKit.h +10 -0
  43. package/ios/libs/libBabylonNative.a +0 -0
  44. package/ios/libs/libCanvas.a +0 -0
  45. package/ios/libs/libGenericCodeGen.a +0 -0
  46. package/ios/libs/libGraphics.a +0 -0
  47. package/ios/libs/libJsRuntime.a +0 -0
  48. package/ios/libs/libMachineIndependent.a +0 -0
  49. package/ios/libs/libNativeCapture.a +0 -0
  50. package/ios/libs/libNativeEngine.a +0 -0
  51. package/ios/libs/libNativeInput.a +0 -0
  52. package/ios/libs/libNativeOptimizations.a +0 -0
  53. package/ios/libs/libNativeTracing.a +0 -0
  54. package/ios/libs/libNativeXr.a +0 -0
  55. package/ios/libs/libOGLCompiler.a +0 -0
  56. package/ios/libs/libOSDependent.a +0 -0
  57. package/ios/libs/libSPIRV.a +0 -0
  58. package/ios/libs/libUrlLib.a +0 -0
  59. package/ios/libs/libWindow.a +0 -0
  60. package/ios/libs/libXMLHttpRequest.a +0 -0
  61. package/ios/libs/libastc-codec.a +0 -0
  62. package/ios/libs/libastc.a +0 -0
  63. package/ios/libs/libbgfx.a +0 -0
  64. package/ios/libs/libbimg.a +0 -0
  65. package/ios/libs/libbx.a +0 -0
  66. package/ios/libs/libglslang.a +0 -0
  67. package/ios/libs/libnapi.a +0 -0
  68. package/ios/libs/libspirv-cross-core.a +0 -0
  69. package/ios/libs/libspirv-cross-glsl.a +0 -0
  70. package/ios/libs/libspirv-cross-hlsl.a +0 -0
  71. package/ios/libs/libspirv-cross-msl.a +0 -0
  72. package/ios/libs/libxr.a +0 -0
  73. package/package.json +54 -42
  74. package/shared/BabylonNative.h +24 -0
  75. package/shared/XrAnchorHelper.h +229 -0
  76. package/shared/XrContextHelper.h +179 -0
  77. package/BabylonModule.ts +0 -33
  78. package/EngineHelpers.ts +0 -14
  79. package/EngineHook.ts +0 -97
  80. package/EngineView.tsx +0 -168
  81. package/index.ts +0 -2
  82. package/ios/BabylonNative.h +0 -24
@@ -7,169 +7,118 @@ import android.view.MotionEvent;
7
7
  import android.view.Surface;
8
8
 
9
9
  import com.facebook.react.bridge.ActivityEventListener;
10
- import com.facebook.react.bridge.JavaScriptContextHolder;
11
10
  import com.facebook.react.bridge.LifecycleEventListener;
12
11
  import com.facebook.react.bridge.ReactContext;
13
12
  import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
14
13
 
15
- import java.util.Hashtable;
16
- import java.util.Iterator;
17
- import java.util.Map;
18
- import java.util.concurrent.CompletableFuture;
19
- import java.util.concurrent.CompletionStage;
14
+ public final class BabylonNativeInterop {
20
15
 
21
- final class BabylonNativeInterop {
22
- // JNI interface
23
- static {
24
- System.loadLibrary("BabylonNative");
16
+ private static class BabylonNative {
17
+ static {
18
+ System.loadLibrary("BabylonNative");
19
+ }
20
+
21
+ public static native void initialize(Context context, long jsiRuntimeRef, CallInvokerHolder jsCallInvokerHolder);
22
+ public static native void setCurrentActivity(Activity activity);
23
+ public static native void pause();
24
+ public static native void resume();
25
+ public static native void updateView(Surface surface);
26
+ public static native void renderView();
27
+ public static native void resetView();
28
+ public static native void updateXRView(Surface surface);
29
+ public static native boolean isXRActive();
30
+ public static native void setTouchButtonState(int pointerId, boolean isDown, int x, int y);
31
+ public static native void setTouchPosition(int pointerId, int x, int y);
25
32
  }
26
33
 
27
- private static boolean isInitialized;
28
- private static final Hashtable<JavaScriptContextHolder, CompletableFuture<Long>> nativeInstances = new Hashtable<>();
29
-
30
- private static native void initialize(Context context);
31
- private static native void setCurrentActivity(Activity activity);
32
- private static native void pause();
33
- private static native void resume();
34
- private static native long create(long jsiRuntimeRef, CallInvokerHolder callInvokerHolder, Surface surface);
35
- private static native void refresh(long instanceRef, Surface surface);
36
- private static native void setPointerButtonState(long instanceRef, int pointerId, int buttonId, boolean isDown, int x, int y);
37
- private static native void setPointerPosition(long instanceRef, int pointerId, int x, int y);
38
- private static native void reset(long instanceRef);
39
- private static native void destroy(long instanceRef);
40
-
41
- // Must be called from the Android UI thread
42
- static void setView(ReactContext reactContext, Surface surface) {
43
- // This is global initialization that only needs to happen once
44
- if (!BabylonNativeInterop.isInitialized) {
45
- BabylonNativeInterop.initialize(reactContext);
46
- BabylonNativeInterop.isInitialized = true;
34
+ private static LifecycleEventListener lifeCycleEventListener;
35
+ private static ActivityEventListener activityEventListener;
36
+
37
+ public static void initialize(ReactContext reactContext) {
38
+ long jsiRuntimeRef = reactContext.getJavaScriptContextHolder().get();
39
+ CallInvokerHolder jsCallInvokerHolder = reactContext.getCatalystInstance().getJSCallInvokerHolder();
40
+ BabylonNative.initialize(reactContext, jsiRuntimeRef, jsCallInvokerHolder);
41
+
42
+ if (BabylonNativeInterop.lifeCycleEventListener != null) {
43
+ reactContext.removeLifecycleEventListener(lifeCycleEventListener);
47
44
  }
48
45
 
49
- BabylonNativeInterop.destroyOldNativeInstances(reactContext);
50
-
51
- CompletableFuture<Long> instanceRefFuture = BabylonNativeInterop.getOrCreateFuture(reactContext);
52
-
53
- reactContext.runOnJSQueueThread(() -> {
54
- Long instanceRef = instanceRefFuture.getNow(null);
55
- if (instanceRef == null)
56
- {
57
- long jsiRuntimeRef = reactContext.getJavaScriptContextHolder().get();
58
- if (jsiRuntimeRef == 0) {
59
- instanceRefFuture.complete(0L);
60
- } else {
61
- instanceRef = BabylonNativeInterop.create(jsiRuntimeRef, reactContext.getCatalystInstance().getJSCallInvokerHolder(), surface);
62
- final long finalInstanceRef = instanceRef;
63
-
64
- reactContext.addLifecycleEventListener(new LifecycleEventListener() {
65
- @Override
66
- public void onHostResume() {
67
- BabylonNativeInterop.setCurrentActivity(reactContext.getCurrentActivity());
68
- BabylonNativeInterop.resume();
69
- }
70
-
71
- @Override
72
- public void onHostPause() {
73
- BabylonNativeInterop.pause();
74
- }
75
-
76
- @Override
77
- public void onHostDestroy() {
78
- BabylonNativeInterop.deinitialize();
79
- }
80
- });
81
-
82
- reactContext.addActivityEventListener(new ActivityEventListener() {
83
- @Override
84
- public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
85
- // Nothing to do here
86
- }
87
-
88
- @Override
89
- public void onNewIntent(Intent intent) {
90
- BabylonNativeInterop.setCurrentActivity(reactContext.getCurrentActivity());
91
- }
92
- });
93
-
94
- instanceRefFuture.complete(finalInstanceRef);
95
- }
96
- } else if (instanceRef != 0) {
97
- BabylonNativeInterop.refresh(instanceRef, surface);
46
+ BabylonNativeInterop.lifeCycleEventListener = new LifecycleEventListener() {
47
+ @Override
48
+ public void onHostResume() {
49
+ BabylonNative.setCurrentActivity(reactContext.getCurrentActivity());
50
+ BabylonNative.resume();
98
51
  }
99
- });
100
- }
101
52
 
102
- static void reportMotionEvent(ReactContext reactContext, MotionEvent motionEvent) {
103
- CompletableFuture<Long> instanceRefFuture = BabylonNativeInterop.nativeInstances.get(reactContext.getJavaScriptContextHolder());
104
- if (instanceRefFuture != null) {
105
- Long instanceRef = instanceRefFuture.getNow(null);
106
- if (instanceRef != null) {
107
- int maskedAction = motionEvent.getActionMasked();
108
- boolean isPointerDown = maskedAction == MotionEvent.ACTION_DOWN || maskedAction == MotionEvent.ACTION_POINTER_DOWN;
109
- boolean isPointerUp = maskedAction == MotionEvent.ACTION_UP || maskedAction == MotionEvent.ACTION_POINTER_UP;
110
- boolean isPointerMove = maskedAction == MotionEvent.ACTION_MOVE;
111
-
112
- if (isPointerDown || isPointerUp) {
113
- int pointerIndex = motionEvent.getActionIndex();
114
- int pointerId = motionEvent.getPointerId(pointerIndex);
115
- int buttonId = motionEvent.getActionButton();
116
- int x = (int)motionEvent.getX(pointerIndex);
117
- int y = (int)motionEvent.getY(pointerIndex);
118
- BabylonNativeInterop.setPointerButtonState(instanceRef, pointerId, buttonId, isPointerDown, x, y);
119
- } else if (isPointerMove) {
120
- for (int pointerIndex = 0; pointerIndex < motionEvent.getPointerCount(); pointerIndex++) {
121
- int pointerId = motionEvent.getPointerId(pointerIndex);
122
- int x = (int)motionEvent.getX(pointerIndex);
123
- int y = (int)motionEvent.getY(pointerIndex);
124
- BabylonNativeInterop.setPointerPosition(instanceRef, pointerId, x, y);
125
- }
126
- }
53
+ @Override
54
+ public void onHostPause() {
55
+ BabylonNative.pause();
127
56
  }
57
+
58
+ @Override
59
+ public void onHostDestroy() {
60
+ }
61
+ };
62
+
63
+ reactContext.addLifecycleEventListener(lifeCycleEventListener);
64
+
65
+ if (BabylonNativeInterop.activityEventListener != null) {
66
+ reactContext.removeActivityEventListener(BabylonNativeInterop.activityEventListener);
128
67
  }
68
+
69
+ BabylonNativeInterop.activityEventListener = new ActivityEventListener() {
70
+ @Override
71
+ public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
72
+ // Nothing to do here
73
+ }
74
+
75
+ @Override
76
+ public void onNewIntent(Intent intent) {
77
+ BabylonNative.setCurrentActivity(reactContext.getCurrentActivity());
78
+ }
79
+ };
80
+
81
+ reactContext.addActivityEventListener(BabylonNativeInterop.activityEventListener);
129
82
  }
130
83
 
131
- // Must be called from the Android UI thread
132
- static CompletionStage<Long> whenInitialized(ReactContext reactContext) {
133
- return BabylonNativeInterop.getOrCreateFuture(reactContext);
84
+ public static void updateView(Surface surface) {
85
+ BabylonNative.updateView(surface);
134
86
  }
135
87
 
136
- // Must be called from the JavaScript thread
137
- static void deinitialize() {
138
- BabylonNativeInterop.destroyOldNativeInstances(null);
88
+ public static void renderView() {
89
+ BabylonNative.renderView();
139
90
  }
140
91
 
141
- static void reset(ReactContext reactContext) {
142
- JavaScriptContextHolder jsContext = reactContext.getJavaScriptContextHolder();
143
- CompletableFuture<Long> instanceRefFuture = BabylonNativeInterop.nativeInstances.get(jsContext);
144
- if (instanceRefFuture != null) {
145
- Long instanceRef = instanceRefFuture.getNow(null);
146
- if (instanceRef != null) {
147
- BabylonNativeInterop.reset(instanceRef);
148
- }
149
- }
92
+ public static void resetView() {
93
+ BabylonNative.resetView();
150
94
  }
151
95
 
152
- private static CompletableFuture<Long> getOrCreateFuture(ReactContext reactContext) {
153
- JavaScriptContextHolder jsContext = reactContext.getJavaScriptContextHolder();
154
- CompletableFuture<Long> instanceRefFuture = BabylonNativeInterop.nativeInstances.get(jsContext);
155
- if (instanceRefFuture == null)
156
- {
157
- instanceRefFuture = new CompletableFuture<>();
158
- BabylonNativeInterop.nativeInstances.put(jsContext, instanceRefFuture);
159
- }
160
- return instanceRefFuture;
96
+ public static void updateXRView(Surface surface) {
97
+ BabylonNative.updateXRView(surface);
98
+ }
99
+
100
+ public static boolean isXRActive() {
101
+ return BabylonNative.isXRActive();
161
102
  }
162
103
 
163
- private static void destroyOldNativeInstances(ReactContext currentReactContext) {
164
- Iterator<Map.Entry<JavaScriptContextHolder, CompletableFuture<Long>>> nativeInstanceIterator = BabylonNativeInterop.nativeInstances.entrySet().iterator();
165
- while (nativeInstanceIterator.hasNext()) {
166
- Map.Entry<JavaScriptContextHolder, CompletableFuture<Long>> nativeInstanceInfo = nativeInstanceIterator.next();
167
- if (currentReactContext == null || nativeInstanceInfo.getKey() != currentReactContext.getJavaScriptContextHolder()) {
168
- Long oldInstanceRef = nativeInstanceInfo.getValue().getNow(null);
169
- if (oldInstanceRef != null && oldInstanceRef != 0) {
170
- BabylonNativeInterop.destroy(oldInstanceRef);
171
- }
172
- nativeInstanceIterator.remove();
104
+ public static void reportMotionEvent(MotionEvent motionEvent) {
105
+ int maskedAction = motionEvent.getActionMasked();
106
+ boolean isPointerDown = maskedAction == MotionEvent.ACTION_DOWN || maskedAction == MotionEvent.ACTION_POINTER_DOWN;
107
+ boolean isPointerUp = maskedAction == MotionEvent.ACTION_UP || maskedAction == MotionEvent.ACTION_POINTER_UP;
108
+ boolean isPointerMove = maskedAction == MotionEvent.ACTION_MOVE;
109
+
110
+ if (isPointerDown || isPointerUp) {
111
+ int pointerIndex = motionEvent.getActionIndex();
112
+ int pointerId = motionEvent.getPointerId(pointerIndex);
113
+ int x = (int)motionEvent.getX(pointerIndex);
114
+ int y = (int)motionEvent.getY(pointerIndex);
115
+ BabylonNative.setTouchButtonState(pointerId, isPointerDown, x, y);
116
+ } else if (isPointerMove) {
117
+ for (int pointerIndex = 0; pointerIndex < motionEvent.getPointerCount(); pointerIndex++) {
118
+ int pointerId = motionEvent.getPointerId(pointerIndex);
119
+ int x = (int)motionEvent.getX(pointerIndex);
120
+ int y = (int)motionEvent.getY(pointerIndex);
121
+ BabylonNative.setTouchPosition(pointerId, x, y);
173
122
  }
174
123
  }
175
124
  }
@@ -11,6 +11,7 @@ import android.view.PixelCopy;
11
11
  import android.view.SurfaceHolder;
12
12
  import android.view.SurfaceView;
13
13
  import android.view.View;
14
+ import android.widget.FrameLayout;
14
15
 
15
16
  import com.facebook.react.bridge.ReactContext;
16
17
  import com.facebook.react.uimanager.UIManagerModule;
@@ -18,36 +19,79 @@ import com.facebook.react.uimanager.events.EventDispatcher;
18
19
 
19
20
  import java.io.ByteArrayOutputStream;
20
21
 
21
- public final class EngineView extends SurfaceView implements SurfaceHolder.Callback, View.OnTouchListener {
22
- private final ReactContext reactContext;
22
+ public final class EngineView extends FrameLayout implements SurfaceHolder.Callback, View.OnTouchListener {
23
+ private static final FrameLayout.LayoutParams childViewLayoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
24
+ private final SurfaceView primarySurfaceView;
25
+ private final SurfaceView xrSurfaceView;
23
26
  private final EventDispatcher reactEventDispatcher;
27
+ private Runnable renderRunnable;
24
28
 
25
29
  public EngineView(ReactContext reactContext) {
26
30
  super(reactContext);
27
- this.reactContext = reactContext;
28
- this.getHolder().addCallback(this);
31
+
32
+ this.primarySurfaceView = new SurfaceView(reactContext);
33
+ this.primarySurfaceView.setLayoutParams(EngineView.childViewLayoutParams);
34
+ this.primarySurfaceView.getHolder().addCallback(this);
35
+ this.addView(this.primarySurfaceView);
36
+
37
+ this.xrSurfaceView = new SurfaceView(reactContext);
38
+ this.xrSurfaceView.setLayoutParams(childViewLayoutParams);
39
+ this.xrSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
40
+ @Override
41
+ public void surfaceCreated(SurfaceHolder holder) {
42
+ // surfaceChanged is also called when the surface is created, so just do all the handling there
43
+ }
44
+
45
+ @Override
46
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
47
+ BabylonNativeInterop.updateXRView(holder.getSurface());
48
+ }
49
+
50
+ @Override
51
+ public void surfaceDestroyed(SurfaceHolder holder) {
52
+ BabylonNativeInterop.updateXRView(null);
53
+ }
54
+ });
55
+ this.xrSurfaceView.setVisibility(View.INVISIBLE);
56
+ this.addView(this.xrSurfaceView);
57
+
29
58
  this.setOnTouchListener(this);
30
- this.reactEventDispatcher = this.reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
59
+
60
+ this.reactEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
31
61
  }
32
62
 
33
63
  @Override
34
64
  public void surfaceCreated(SurfaceHolder surfaceHolder) {
35
- // surfaceChanged is also called when the surface is created, so just do all the handling there
65
+ this.renderRunnable = new Runnable() {
66
+ @Override
67
+ public void run() {
68
+ if (BabylonNativeInterop.isXRActive()) {
69
+ EngineView.this.xrSurfaceView.setVisibility(View.VISIBLE);
70
+ } else {
71
+ EngineView.this.xrSurfaceView.setVisibility(View.INVISIBLE);
72
+ }
73
+
74
+ BabylonNativeInterop.renderView();
75
+ EngineView.this.postOnAnimation(this);
76
+ }
77
+ };
78
+ this.postOnAnimation(this.renderRunnable);
36
79
  }
37
80
 
38
81
  @Override
39
82
  public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int width, int height) {
40
- BabylonNativeInterop.setView(this.reactContext, surfaceHolder.getSurface());
83
+ BabylonNativeInterop.updateView(surfaceHolder.getSurface());
41
84
  }
42
85
 
43
86
  @Override
44
87
  public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
45
-
88
+ this.removeCallbacks(this.renderRunnable);
89
+ this.renderRunnable = null;
46
90
  }
47
91
 
48
92
  @Override
49
93
  public boolean onTouch(View view, MotionEvent motionEvent) {
50
- BabylonNativeInterop.reportMotionEvent(this.reactContext, motionEvent);
94
+ BabylonNativeInterop.reportMotionEvent(motionEvent);
51
95
  return true;
52
96
  }
53
97
 
@@ -70,13 +114,18 @@ public final class EngineView extends SurfaceView implements SurfaceHolder.Callb
70
114
  helperThread.start();
71
115
  final Handler helperThreadHandler = new Handler(helperThread.getLooper());
72
116
 
117
+ SurfaceView surfaceView = this.primarySurfaceView;
118
+ if (BabylonNativeInterop.isXRActive()) {
119
+ surfaceView = this.xrSurfaceView;
120
+ }
121
+
73
122
  // Request the pixel copy.
74
- PixelCopy.request(this, bitmap, (copyResult) -> {
123
+ PixelCopy.request(surfaceView, bitmap, (copyResult) -> {
75
124
  // If the pixel copy was a success then convert the image to a base 64 encoded jpeg and fire the event.
76
125
  String encoded = "";
77
126
  if (copyResult == PixelCopy.SUCCESS) {
78
127
  ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();
79
- bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayStream);
128
+ bitmap.compress(Bitmap.CompressFormat.JPEG, 80, byteArrayStream);
80
129
  byte[] byteArray = byteArrayStream.toByteArray();
81
130
  bitmap.recycle();
82
131
  encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);
package/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './EngineView';
2
+ export * from './EngineHook';
3
+ export * from './NativeCapture';
4
+ export * from './FontFace';
package/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './EngineView';
2
+ export * from './EngineHook';
3
+ export * from './NativeCapture';
4
+ export * from './FontFace';
5
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../Modules/@babylonjs/react-native/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
@@ -19,16 +19,15 @@ RCT_EXPORT_MODULE();
19
19
  @synthesize bridge = _bridge;
20
20
 
21
21
  RCT_EXPORT_METHOD(initialize:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
22
- [BabylonNativeInterop whenInitialized:self.bridge resolve:resolve];
23
- }
24
-
25
- RCT_EXPORT_METHOD(whenInitialized:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
26
- [BabylonNativeInterop whenInitialized:self.bridge resolve:resolve];
22
+ self.bridge.jsCallInvoker->invokeAsync([bridge{ self.bridge }, resolve]() {
23
+ [BabylonNativeInterop initialize:bridge];
24
+ resolve([NSNull null]);
25
+ });
27
26
  }
28
27
 
29
- RCT_EXPORT_METHOD(reset:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
30
- self.bridge.jsCallInvoker->invokeAsync([resolve]() {
31
- [BabylonNativeInterop reset];
28
+ RCT_EXPORT_METHOD(resetView:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
29
+ dispatch_async(dispatch_get_main_queue(), ^{
30
+ [BabylonNativeInterop resetView];
32
31
  resolve([NSNull null]);
33
32
  });
34
33
  }
@@ -4,8 +4,11 @@
4
4
  #import <React/RCTBridge.h>
5
5
 
6
6
  @interface BabylonNativeInterop : NSObject
7
- + (void)setView:(RCTBridge*)bridge jsRunLoop:(NSRunLoop*)jsRunLoop mktView:(MTKView*)mtkView;
8
- + (void)reportTouchEvent:(NSSet<UITouch*>*)touches withEvent:(UIEvent*)event;
9
- + (void)whenInitialized:(RCTBridge*)bridge resolve:(RCTPromiseResolveBlock)resolve;
10
- + (void)reset;
7
+ + (void)initialize:(RCTBridge*)bridge;
8
+ + (void)updateView:(MTKView*)mtkView;
9
+ + (void)renderView;
10
+ + (void)resetView;
11
+ + (void)updateXRView:(MTKView*)mtkView;
12
+ + (bool)isXRActive;
13
+ + (void)reportTouchEvent:(MTKView*)mtkView touches:(NSSet<UITouch*>*)touches event:(UIEvent*)event;
11
14
  @end