Capturing ARKit scene (Like react-native-arkit
) into react-native-webrtc
video stream.
- Required use the react-native-webrtc patch. (You can use
patch-package
) - Add dependency with
yarn add react-native-webrtc-ar-session
- You may need to run
react-native link react-native-webrtc-ar-session
or autolinking.
After using this react-native-webrtc patch, we need to set ar: true
in video
property of mediaDevices.getUserMedia(...)
. (See the example)
import {
isARWorldTrackingSupported,
startCapturingARView,
stopCapturingARView,
} from 'react-native-webrtc-ar-session'
// Check the device is support AR World Tracking
isARWorldTrackingSupported()
// Start capturing <ARKit /> view into WebRTC video stream
// You can call it after WebRTC and ARKit view is ready
startCapturingARView({
frameRate: 30, // Default to ARSCNView.preferredFramesPerSecond (Default: 60)
}).then(({ success }) => console.log('Start session:', success))
stopCapturingARView()
You can have native ARSCNView setup without react-native-arkit
:
// Add to your header file
#import <RNWebRTCARSession/RNWebRTCARSession.h>
[RNWebRTCARSession setArView:__your_arscnview_here__];