react-native-arkit icon indicating copy to clipboard operation
react-native-arkit copied to clipboard

ARKit 2.0

Open birkir opened this issue 6 years ago • 3 comments

New API's exposed

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()}
/>

birkir avatar Jun 05 '18 19:06 birkir

when is this going to be implemented ?

PerspectivesLab avatar Jul 14 '18 01:07 PerspectivesLab

@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

macrozone avatar Sep 06 '18 09:09 macrozone

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

code-matt avatar Feb 22 '20 14:02 code-matt