react-native-arkit
react-native-arkit copied to clipboard
ARKit 2.0
New API's exposed
- AREnvironmentProbeAnchor
- ARWorldMap
- ARReferenceObject
- ARObjectAnchor
- ARObjectScanningConfiguration
- ARImageTrackingConfiguration
With the ARWorldMap being the most anticipated feature yet in ARKit, we could expose it something like this...
Get worldMapStatus
RCT_EXPORT_VIEW_PROPERTY(onWorldMappingStatus, RCTBubblingEventBlock)
if (self.onWorldMappingStatus) {
ARWorldMappingStatus * status = self.arView.session.currentFrame.worldMappingStatus;
if (status != self.worldMappingStatus) {
dispatch_async(dispatch_get_main_queue(), ^{
self.onWorldMappingStatus(@{
@"state": @(status),
});
});
self.worldMappingStatus = status;
}
}
Receive worldMap
RCT_EXPORT_VIEW_PROPERTY(worldMap, NSObject);
RCT_EXPORT_METHOD(getCurrentWorldMap:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
resolve([[ARKit sharedInstance] getCurrentWorldMap:resolve reject:reject]);
}
- (void)getCurrentWorldMap:(RCTARKitResolve)resolve reject:(RCTARKitReject)reject {
[session getCurrentWorldMapWithCompletionHandler:^(ARWorldMap * _Nullable worldMap, NSError * _Nullable error) {
if (error) {
reject(error);
} else {
resolve(worldMap);
}
}];
}
Usage?
// device 1
<ARKit
onWorldMappingStatus={async ({ status }) => {
if (status === 'ARWorldMappingStatusMapped') {
await cloud.set(await arkit.getCurrentWorldMap());
}
}}
/>
// device 2
<ARKit
worldMap={await cloud.get()}
/>
when is this going to be implemented ?
@PerspectivesLab I was not so active on the project, but I might get back to it soon. It should not be a big thing to do so.
@birkir did you try it out? if so, could you open up a pull request? then we can continue on that
I have a PR open for this, well the worldmap sharing bit. @birkir I can't tell me how much your little snip actually helped me when I was first getting going, thanks! I do not have anchors yet which will help syncing the worldmaps greatly