From 774f726163f0861698ef56c30b2c9e757eb01e8a Mon Sep 17 00:00:00 2001 From: Joseph Dibble Date: Wed, 10 May 2023 19:37:07 +0000 Subject: [PATCH] ARCore iOS SDK 1.37.0 --- Examples/AugmentedFacesExample/Podfile | 2 +- .../CloudAnchorExample/CloudAnchorManager.h | 34 +- .../CloudAnchorExample/CloudAnchorManager.m | 104 +-- .../ExampleViewController.m | 128 +-- Examples/CloudAnchorExample/Podfile | 2 +- .../GeospatialExample/ViewController.m | 702 ++++++++++++----- Examples/GeospatialExample/Podfile | 2 +- .../CloudAnchorManager.h | 28 +- .../CloudAnchorManager.m | 29 +- .../HostViewController.h | 2 +- .../HostViewController.m | 46 +- .../ResolveViewController.m | 88 +-- Examples/PersistentCloudAnchorExample/Podfile | 2 +- LICENSE | 743 +++++++++++++++++- Package.swift | 22 +- 15 files changed, 1456 insertions(+), 478 deletions(-) diff --git a/Examples/AugmentedFacesExample/Podfile b/Examples/AugmentedFacesExample/Podfile index 0a3f434..7794025 100644 --- a/Examples/AugmentedFacesExample/Podfile +++ b/Examples/AugmentedFacesExample/Podfile @@ -1,4 +1,4 @@ target 'AugmentedFacesExample' use_frameworks! platform :ios, '11.0' -pod 'ARCore/AugmentedFaces', '~> 1.36.0' \ No newline at end of file +pod 'ARCore/AugmentedFaces', '~> 1.37.0' \ No newline at end of file diff --git a/Examples/CloudAnchorExample/CloudAnchorExample/CloudAnchorManager.h b/Examples/CloudAnchorExample/CloudAnchorExample/CloudAnchorManager.h index 3395012..15d7407 100644 --- a/Examples/CloudAnchorExample/CloudAnchorExample/CloudAnchorManager.h +++ b/Examples/CloudAnchorExample/CloudAnchorExample/CloudAnchorManager.h @@ -20,8 +20,11 @@ @class CloudAnchorManager; @class GARAnchor; @class GARFrame; +@class GARHostCloudAnchorFuture; +@class GARResolveCloudAnchorFuture; @class GARSession; -@protocol GARSessionDelegate; + +typedef NS_ENUM(NSInteger, GARCloudAnchorState); NS_ASSUME_NONNULL_BEGIN @@ -29,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN * Delegate for receiving callbacks from a CloudAnchorManager and the underlying GARSession. All * methods are optional. */ -@protocol CloudAnchorManagerDelegate +@protocol CloudAnchorManagerDelegate /** * Invoked after the ARSessionDelegate:session:didUpdateFrame: method was called on the @@ -61,19 +64,21 @@ NS_ASSUME_NONNULL_BEGIN failedToCreateRoomWithError:(NSError *)error; /** - * Invoked after a call to GARSession:resolveCloudAnchorWithIdentifier failed. + * Invoked after a call to GARSession:resolveCloudAnchorWithIdentifier:completionHandler:error. * * @param manager The CloudAnchorManager which received CloudAnchorManager#createRoom. - * @param error An NSError with information about what failed. + * @param future The future for the async resolve operation, or nil if there was an error. + * @param error An NSError with information about what failed, or nil if there was no error. */ - (void)cloudAnchorManager:(CloudAnchorManager *)manager - resolveCloudAnchorReturnNilWithError:(NSError *)error; + startedResolvingCloudAnchor:(nullable GARResolveCloudAnchorFuture *)future + error:(nullable NSError *)error; @end @interface CloudAnchorManager : NSObject -@property (nonatomic, weak, setter=setDelegate:) id delegate; +@property(nonatomic, weak) id delegate; - (instancetype)initWithARSceneView:(ARSCNView *)scnView; @@ -90,7 +95,7 @@ NS_ASSUME_NONNULL_BEGIN * @param roomCode A room code used to store information about cloud anchors in firebase. * @param anchor The anchor to be mapped to the given room code in firebase. */ -- (void)updateRoom:(NSString *)roomCode withAnchor:(GARAnchor *)anchor; +- (void)updateRoom:(NSString *)roomCode withAnchorId:(NSString *)anchorId; /** * Attempt to resolve the last hosted anchor for the given room code. If there is a cloud anchor @@ -98,10 +103,10 @@ NS_ASSUME_NONNULL_BEGIN * resolved. * * @param roomCode A room code used to store information about cloud anchors in firebase. - * @param completion Callback to invoke if the room has an anchor associated with it and a resolve - * attempt is in progress. + * @param completion Callback to invoke when the anchor has finished resolving. */ -- (void)resolveAnchorWithRoomCode:(NSString *)roomCode completion:(void (^)(GARAnchor *))completion; +- (void)resolveAnchorWithRoomCode:(NSString *)roomCode + completion:(void (^)(GARAnchor *_Nullable, GARCloudAnchorState))completion; /** * Stop observing firebase messages related to the given room code. @@ -114,12 +119,15 @@ NS_ASSUME_NONNULL_BEGIN * Host a Cloud Anchor corresponding to the given ARAnchor. * * @param arAnchor An ARAnchor object to be hosted within the hotspot generated by the session. + * @param completion Callback to invoke when the anchor has finished hosting. * @param error A return address which an error will be written to, if one occurs. * - * @return The new GARAnchor, or `nil` if there is an error. + * @return The hosting future, or `nil` if there is an error. */ -- (GARAnchor *)hostCloudAnchor:(ARAnchor *)arAnchor error:(NSError **)error; - +- (GARHostCloudAnchorFuture *)hostCloudAnchor:(ARAnchor *)arAnchor + completion:(void (^)(NSString *_Nullable, + GARCloudAnchorState))completion + error:(NSError **)error; /** * Remove the passed GARAnchor from the underlying GARSession diff --git a/Examples/CloudAnchorExample/CloudAnchorExample/CloudAnchorManager.m b/Examples/CloudAnchorExample/CloudAnchorExample/CloudAnchorManager.m index 65b6df7..76efc68 100644 --- a/Examples/CloudAnchorExample/CloudAnchorExample/CloudAnchorManager.m +++ b/Examples/CloudAnchorExample/CloudAnchorExample/CloudAnchorManager.m @@ -69,17 +69,10 @@ - (instancetype)initWithARSceneView:(id)sceneView { [self popupAlertWindowOnError:alertWindowTitle alertMessage:alertMessage]; return nil; } - - _gSession.delegateQueue = dispatch_get_main_queue(); } return self; } -- (void)setDelegate:(id)delegate { - _delegate = delegate; - self.gSession.delegate = delegate; -} - #pragma mark - ARSessionDelegate - (void)session:(ARSession *)session didUpdateFrame:(ARFrame *)frame { @@ -147,68 +140,54 @@ - (void)createRoom { }]; } -- (void)updateRoom:(NSString *)roomCode withAnchor:(GARAnchor *)anchor { +- (void)updateRoom:(NSString *)roomCode withAnchorId:(NSString *)anchorId { [[[[self.firebaseReference child:@"hotspot_list"] child:roomCode] child:@"hosted_anchor_id"] - setValue:anchor.cloudIdentifier]; + setValue:anchorId]; long long timestampInteger = (long long)([[NSDate date] timeIntervalSince1970] * 1000); NSNumber *timestamp = [NSNumber numberWithLongLong:timestampInteger]; [[[[self.firebaseReference child:@"hotspot_list"] child:roomCode] child:@"updated_at_timestamp"] setValue:timestamp]; } +- (void)doResolveAnchor:(FIRDataSnapshot *)snapshot + roomCode:(NSString *)roomCode + completion:(void (^)(GARAnchor *, GARCloudAnchorState))completion { + NSString *anchorId = nil; + if ([snapshot.value isKindOfClass:[NSDictionary class]]) { + NSDictionary *value = (NSDictionary *)snapshot.value; + anchorId = (NSString *)value[@"hosted_anchor_id"]; + } + + if (anchorId) { + [[[self.firebaseReference child:@"hotspot_list"] child:roomCode] removeAllObservers]; + + // Now that we have the anchor ID from firebase, we resolve the anchor. + NSError *error = nil; + GARResolveCloudAnchorFuture *garFuture = + [self.gSession resolveCloudAnchorWithIdentifier:anchorId + completionHandler:completion + error:&error]; + + // Synchronous failure. + if (garFuture == nil) { + NSString *alertWindowTitle = @"An error occurred"; + NSString *alertMessage = [NSString + stringWithFormat:@"Error resolving cloud anchor: %@", [error localizedDescription]]; + [self popupAlertWindowOnError:alertWindowTitle alertMessage:alertMessage]; + } + + // Pass message to delegate for state management + [self.delegate cloudAnchorManager:self startedResolvingCloudAnchor:garFuture error:error]; + } +} + - (void)resolveAnchorWithRoomCode:(NSString *)roomCode - completion:(void (^)(GARAnchor *))completion { + completion:(void (^)(GARAnchor *, GARCloudAnchorState))completion { __weak CloudAnchorManager *weakSelf = self; [[[self.firebaseReference child:@"hotspot_list"] child:roomCode] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *_Nonnull snapshot) { - CloudAnchorManager *strongSelf = weakSelf; - if (strongSelf == nil) { - return; - } - - NSString *anchorId = nil; - if ([snapshot.value isKindOfClass:[NSDictionary class]]) { - NSDictionary *value = (NSDictionary *)snapshot.value; - anchorId = (NSString *)value[@"hosted_anchor_id"]; - } - - if (anchorId) { - [[[strongSelf.firebaseReference child:@"hotspot_list"] child:roomCode] - removeAllObservers]; - - // Now that we have the anchor ID from firebase, we resolve the anchor. - // Synchronous failures will return nil. The causes may be invalid arguments, etc. - // Asynchronous failures (garAnchor is returned as a nonnull) is handled by - // session:didFailToResolveAnchor. Success is handled by the delegate methods - // session:didResolveAnchor. When garAnchor is returned as a nil, it means - // synchronous failures happened where no delegate is called. When garAnchor is - // returned as a nonnull, while some asynchronous failure happened, it is handled - // by session:didFailToResolveAnchor. - NSError *error = nil; - GARAnchor *garAnchor = - [strongSelf.gSession resolveCloudAnchorWithIdentifier:anchorId error:&error]; - - // Synchronous failure. Refer to the code - if (garAnchor == nil) { - NSString *alertWindowTitle = @"An error occurred"; - NSString *alertMessage = [NSString - stringWithFormat: - @"GARAnchor is returned as a nil in " - @"CloudAnchorManager:resolveAnchorWithRoomCode. Error description: %@", - [error localizedDescription]]; - [self popupAlertWindowOnError:alertWindowTitle alertMessage:alertMessage]; - - // Synchronous error in GARSession:resolveCloudAnchorWithIdentifier. - // Pass message to delegate for state management - [self.delegate cloudAnchorManager:self - resolveCloudAnchorReturnNilWithError:error]; - - return; - } - - completion(garAnchor); - } + [weakSelf doResolveAnchor:snapshot roomCode:roomCode completion:completion]; }]; } @@ -216,10 +195,13 @@ - (void)stopResolvingAnchorWithRoomCode:(NSString *)roomCode { [[[self.firebaseReference child:@"hotspot_list"] child:roomCode] removeAllObservers]; } -- (GARAnchor *)hostCloudAnchor:(ARAnchor *)arAnchor error:(NSError **)error { - // To share an anchor, we call host anchor here on the ARCore session. - // session:didHostAnchor: session:didFailToHostAnchor: will get called appropriately. - return [self.gSession hostCloudAnchor:arAnchor error:error]; +- (GARHostCloudAnchorFuture *)hostCloudAnchor:(ARAnchor *)arAnchor + completion:(void (^)(NSString *, GARCloudAnchorState))completion + error:(NSError **)error { + return [self.gSession hostCloudAnchor:arAnchor + TTLDays:1 + completionHandler:completion + error:error]; } - (void)removeAnchor:(GARAnchor *)anchor { diff --git a/Examples/CloudAnchorExample/CloudAnchorExample/ExampleViewController.m b/Examples/CloudAnchorExample/CloudAnchorExample/ExampleViewController.m index 270fd13..dcd2bbc 100644 --- a/Examples/CloudAnchorExample/CloudAnchorExample/ExampleViewController.m +++ b/Examples/CloudAnchorExample/CloudAnchorExample/ExampleViewController.m @@ -48,9 +48,7 @@ typedef NS_ENUM(NSInteger, HelloARState) { static NSString * const kPrivacyAlertLinkURL = @"https://developers.google.com/ar/data-privacy"; -@interface ExampleViewController () +@interface ExampleViewController () @property(nonatomic, strong) ARAnchor *arAnchor; @property(nonatomic, strong) GARAnchor *garAnchor; @@ -63,6 +61,9 @@ @interface ExampleViewController () *)touches withEvent:(UIEvent *)event { #pragma mark - Anchor Hosting / Resolving +- (void)handleResolveAnchor:(GARAnchor *)anchor cloudState:(GARCloudAnchorState)cloudState { + if (self.state != HelloARStateResolving) { + return; + } + if (cloudState == GARCloudAnchorStateSuccess) { + self.garAnchor = anchor; + self.resolvedAnchorNode = [self andyNode]; + self.resolvedAnchorNode.simdTransform = anchor.transform; + [self.sceneView.scene.rootNode addChildNode:self.resolvedAnchorNode]; + } + + [self enterState:HelloARStateResolvingFinished]; +} + - (void)resolveAnchorWithRoomCode:(NSString *)roomCode { self.roomCode = roomCode; [self enterState:HelloARStateResolving]; - [self.cloudAnchorManager resolveAnchorWithRoomCode:roomCode completion:^(GARAnchor *anchor) { - self.garAnchor = anchor; - }]; + + __weak ExampleViewController *weakSelf = self; + [self.cloudAnchorManager + resolveAnchorWithRoomCode:roomCode + completion:^(GARAnchor *anchor, GARCloudAnchorState cloudState) { + [weakSelf handleResolveAnchor:anchor cloudState:cloudState]; + }]; +} + +- (void)handleHostAnchor:(NSString *)anchorId cloudState:(GARCloudAnchorState)cloudState { + if (self.state != HelloARStateHosting) { + return; + } + if (cloudState == GARCloudAnchorStateSuccess) { + [self.cloudAnchorManager updateRoom:self.roomCode withAnchorId:anchorId]; + } + [self enterState:HelloARStateHostingFinished]; } - (void)addAnchorWithTransform:(matrix_float4x4)transform { self.arAnchor = [[ARAnchor alloc] initWithTransform:transform]; [self.sceneView.session addAnchor:self.arAnchor]; - self.garAnchor = [self.cloudAnchorManager hostCloudAnchor:self.arAnchor error:nil]; + __weak ExampleViewController *weakSelf = self; + self.hostFuture = [self.cloudAnchorManager + hostCloudAnchor:self.arAnchor + completion:^(NSString *anchorId, GARCloudAnchorState cloudState) { + [weakSelf handleHostAnchor:anchorId cloudState:cloudState]; + } + error:nil]; [self enterState:HelloARStateHosting]; } @@ -185,7 +220,7 @@ - (void)cloudAnchorManager:(CloudAnchorManager *)manager self.message = [NSString stringWithFormat: @"garFrame is returned as a nil in " - @"CloudAnchorManager:sessioin:session:didUPdateFrame: Error description: %@", + @"CloudAnchorManager:sessioin:session:didUpdateFrame: Error description: %@", [error localizedDescription]]; [self updateMessageLabel]; return; @@ -199,53 +234,18 @@ - (void)cloudAnchorManager:(CloudAnchorManager *)manager } - (void)cloudAnchorManager:(CloudAnchorManager *)manager - resolveCloudAnchorReturnNilWithError:(NSError *)error { - self.message = [NSString - stringWithFormat:@"Resolved Cloud Anchor returned nil" - @"GARSession:resolveCloudAnchorWithIdentifier Error description: %@", - [error localizedDescription]]; - [self updateMessageLabel]; - self.garAnchor = nil; - [self enterState:HelloARStateResolvingFinished]; -} - -#pragma mark - GARSessionDelegate - -- (void)session:(GARSession *)session didHostAnchor:(GARAnchor *)anchor { - if (self.state != HelloARStateHosting || ![anchor isEqual:self.garAnchor]) { - return; - } - self.garAnchor = anchor; - [self.cloudAnchorManager updateRoom:self.roomCode withAnchor:anchor]; - [self enterState:HelloARStateHostingFinished]; -} - -- (void)session:(GARSession *)session didFailToHostAnchor:(GARAnchor *)anchor { - if (self.state != HelloARStateHosting || ![anchor isEqual:self.garAnchor]) { - return; - } - self.garAnchor = anchor; - [self enterState:HelloARStateHostingFinished]; -} - -- (void)session:(GARSession *)session didResolveAnchor:(GARAnchor *)anchor { - if (self.state != HelloARStateResolving || ![anchor isEqual:self.garAnchor]) { - return; - } - - self.garAnchor = anchor; - self.resolvedAnchorNode = [self andyNode]; - self.resolvedAnchorNode.simdTransform = anchor.transform; - [self.sceneView.scene.rootNode addChildNode:self.resolvedAnchorNode]; - [self enterState:HelloARStateResolvingFinished]; -} - -- (void)session:(GARSession *)session didFailToResolveAnchor:(GARAnchor *)anchor { - if (self.state != HelloARStateResolving || ![anchor isEqual:self.garAnchor]) { - return; + startedResolvingCloudAnchor:(GARResolveCloudAnchorFuture *)future + error:(NSError *)error { + if (future) { + self.resolveFuture = future; + } else { + self.message = [NSString + stringWithFormat:@"Resolved Cloud Anchor returned nil" + @"GARSession:resolveCloudAnchorWithIdentifier Error description: %@", + [error localizedDescription]]; + [self updateMessageLabel]; + [self enterState:HelloARStateResolvingFinished]; } - self.garAnchor = anchor; - [self enterState:HelloARStateResolvingFinished]; } # pragma mark - Helper Methods @@ -422,6 +422,14 @@ - (void)enterState:(HelloARState)state { self.resolveTimer = nil; } } + if (self.hostFuture) { + [self.hostFuture cancel]; + self.hostFuture = nil; + } + if (self.resolveFuture) { + [self.resolveFuture cancel]; + self.resolveFuture = nil; + } [self toggleButton:self.hostButton enabled:YES title:@"HOST"]; [self toggleButton:self.resolveButton enabled:YES title:@"RESOLVE"]; self.roomCode = @""; @@ -440,9 +448,9 @@ - (void)enterState:(HelloARState)state { self.message = @"Hosting anchor..."; break; case HelloARStateHostingFinished: - self.message = - [NSString stringWithFormat:@"Finished hosting: %@", - [self cloudStateString:self.garAnchor.cloudState]]; + self.message = [NSString + stringWithFormat:@"Finished hosting: %@", + [self cloudStateString:self.hostFuture.resultCloudAnchorState]]; break; case HelloARStateEnterRoomCode: [self showRoomCodeDialog]; @@ -464,9 +472,9 @@ - (void)enterState:(HelloARState)state { [self.resolveTimer invalidate]; self.resolveTimer = nil; } - self.message = - [NSString stringWithFormat:@"Finished resolving: %@", - [self cloudStateString:self.garAnchor.cloudState]]; + self.message = [NSString + stringWithFormat:@"Finished resolving: %@", + [self cloudStateString:self.resolveFuture.resultCloudAnchorState]]; break; } self.state = state; diff --git a/Examples/CloudAnchorExample/Podfile b/Examples/CloudAnchorExample/Podfile index a087ba2..391cba4 100644 --- a/Examples/CloudAnchorExample/Podfile +++ b/Examples/CloudAnchorExample/Podfile @@ -1,5 +1,5 @@ target 'CloudAnchorExample' use_frameworks! platform :ios, '11.0' -pod 'ARCore/CloudAnchors', '~> 1.36.0' +pod 'ARCore/CloudAnchors', '~> 1.37.0' pod 'Firebase/Database', '~> 8.0' diff --git a/Examples/GeospatialExample/GeospatialExample/ViewController.m b/Examples/GeospatialExample/GeospatialExample/ViewController.m index 385160d..ec77c6c 100644 --- a/Examples/GeospatialExample/GeospatialExample/ViewController.m +++ b/Examples/GeospatialExample/GeospatialExample/ViewController.m @@ -41,9 +41,9 @@ // Time after showing resolving terrain anchors no result yet message. static const NSTimeInterval kDurationNoTerrainAnchorResult = 10; -// This sample allows up to 5 simultaneous anchors, although in principal ARCore supports an -// unlimited number. -static const NSUInteger kMaxAnchors = 5; +// This sample allows up to |kMaxAnchors| simultaneous anchors, although in principal ARCore +// supports an unlimited number. +static const NSUInteger kMaxAnchors = 20; static NSString *const kPretrackingMessage = @"Localizing your device to set anchor."; static NSString *const kLocalizationTip = @@ -75,14 +75,16 @@ @"https://developers.google.com/ar/data-privacy"; // Show VPS availability notice before using features. -static NSString *const kVPSAvailabilityNoticeUserDefaultsKey = @"VPS_availability_notice_acknowledged"; +static NSString *const kVPSAvailabilityNoticeUserDefaultsKey = + @"VPS_availability_notice_acknowledged"; // Title of the VPS availability notice prompt. static NSString *const kVPSAvailabilityTitle = @"VPS not available"; // Content of the VPS availability notice prompt. static NSString *const kVPSAvailabilityText = - @"Your current location does not have VPS coverage. Your session will be using your GPS signal only if VPS is not available."; + @"The Google Visual Positioning Service (VPS) is not available at your current location. " + @"Location data may not be as accurate."; typedef NS_ENUM(NSInteger, LocalizationState) { LocalizationStatePretracking = 0, @@ -91,6 +93,12 @@ typedef NS_ENUM(NSInteger, LocalizationState) { LocalizationStateFailed = -1, }; +typedef NS_ENUM(NSInteger, AnchorType) { + AnchorTypeGeospatial = 0, + AnchorTypeTerrain = 1, + AnchorTypeRooftop = 2, +}; + @interface ViewController () /** Location manager used to request and check for location permissions. */ @@ -119,13 +127,16 @@ @interface ViewController () *terrainAnchorIDToStartTime; - -/** Set of finished terrain anchor IDs to remove at next frame update. */ -@property(nonatomic) NSMutableSet *anchorIDsToRemove; +/** Error message, if any, of last attempted anchor resolution */ +@property(nonatomic) NSString *resolveAnchorErrorMessage; /** The current localization state. */ @property(nonatomic) LocalizationState localizationState; @@ -155,8 +163,20 @@ @interface ViewController () *streetscapeGeometryNodes; + +/** Is StreetscapeGeometry enabled */ +@property(nonatomic) BOOL isStreetscapeGeometryEnabled; + +/** ARKit plane nodes */ +@property(nonatomic) NSMutableSet *planeNodes; + +/** Active futures for resolving terrain or rooftop anchors. */ +@property(nonatomic) int activeFutures; @end @@ -166,8 +186,6 @@ - (void)viewDidLoad { [super viewDidLoad]; self.markerNodes = [NSMutableDictionary dictionary]; - self.terrainAnchorIDToStartTime = [NSMutableDictionary dictionary]; - self.anchorIDsToRemove = [NSMutableSet set]; ARSCNView *scnView = [[ARSCNView alloc] init]; scnView = [[ARSCNView alloc] init]; @@ -180,6 +198,15 @@ - (void)viewDidLoad { self.scnView.delegate = self; self.scnView.debugOptions = ARSCNDebugOptionShowFeaturePoints; + self.planeNodes = [NSMutableSet set]; + self.activeFutures = 0; + + self.streetscapeGeometryParentNode = [SCNNode node]; + self.streetscapeGeometryParentNode.hidden = NO; + [self.scene.rootNode addChildNode:self.streetscapeGeometryParentNode]; + self.streetscapeGeometryNodes = [[NSMutableDictionary alloc] init]; + self.isStreetscapeGeometryEnabled = YES; + [self.view addSubview:self.scnView]; UIFont *font = [UIFont systemFontOfSize:kFontSize]; @@ -214,21 +241,23 @@ - (void)viewDidLoad { self.statusLabel = statusLabel; [self.scnView addSubview:statusLabel]; - UIButton *addAnchorButton = [UIButton buttonWithType:UIButtonTypeSystem]; - addAnchorButton.translatesAutoresizingMaskIntoConstraints = NO; - [addAnchorButton setTitle:@"ADD CAMERA ANCHOR" forState:UIControlStateNormal]; - addAnchorButton.titleLabel.font = boldFont; - [addAnchorButton addTarget:self - action:@selector(addAnchorButtonPressed) - forControlEvents:UIControlEventTouchUpInside]; - addAnchorButton.hidden = YES; - self.addAnchorButton = addAnchorButton; - [self.view addSubview:addAnchorButton]; - - UISwitch *terrainAnchorSwitch = [[UISwitch alloc] init]; - terrainAnchorSwitch.translatesAutoresizingMaskIntoConstraints = NO; - [self.view addSubview:terrainAnchorSwitch]; - self.terrainAnchorSwitch = terrainAnchorSwitch; + UISwitch *streetscapeGeometrySwitch = [[UISwitch alloc] init]; + streetscapeGeometrySwitch.translatesAutoresizingMaskIntoConstraints = NO; + [streetscapeGeometrySwitch setOn:YES]; + [self.view addSubview:streetscapeGeometrySwitch]; + self.streetscapeGeometrySwitch = streetscapeGeometrySwitch; + + UIButton *anchorModeSelector = [UIButton buttonWithType:UIButtonTypeSystem]; + [anchorModeSelector setTitle:@"ANCHOR SETTINGS" forState:UIControlStateNormal]; + [anchorModeSelector setImage:[UIImage systemImageNamed:@"gearshape.fill"] + forState:UIControlStateNormal]; + anchorModeSelector.hidden = YES; + anchorModeSelector.titleLabel.font = boldFont; + anchorModeSelector.translatesAutoresizingMaskIntoConstraints = NO; + anchorModeSelector.menu = [self anchorSettingsMenu]; + anchorModeSelector.showsMenuAsPrimaryAction = YES; + [self.view addSubview:anchorModeSelector]; + self.anchorModeSelector = anchorModeSelector; UILabel *switchLabel = [[UILabel alloc] init]; switchLabel.translatesAutoresizingMaskIntoConstraints = NO; @@ -237,7 +266,7 @@ - (void)viewDidLoad { switchLabel.numberOfLines = 1; self.switchLabel = switchLabel; [self.scnView addSubview:switchLabel]; - self.switchLabel.text = @"TERRAIN"; + self.switchLabel.text = @"SHOW GEOMETRY"; UIButton *clearAllAnchorsButton = [UIButton buttonWithType:UIButtonTypeSystem]; clearAllAnchorsButton.translatesAutoresizingMaskIntoConstraints = NO; @@ -272,16 +301,17 @@ - (void)viewDidLoad { [statusLabel.rightAnchor constraintEqualToAnchor:self.view.rightAnchor].active = YES; [statusLabel.heightAnchor constraintEqualToConstant:160].active = YES; - [addAnchorButton.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor] + [streetscapeGeometrySwitch.bottomAnchor constraintEqualToAnchor:self.statusLabel.bottomAnchor] .active = YES; - [addAnchorButton.rightAnchor constraintEqualToAnchor:self.view.rightAnchor].active = YES; + [streetscapeGeometrySwitch.rightAnchor constraintEqualToAnchor:self.view.rightAnchor].active = + YES; - [terrainAnchorSwitch.topAnchor constraintEqualToAnchor:self.statusLabel.topAnchor].active = YES; - [terrainAnchorSwitch.rightAnchor constraintEqualToAnchor:self.view.rightAnchor].active = YES; + [anchorModeSelector.topAnchor constraintEqualToAnchor:self.statusLabel.topAnchor].active = YES; + [anchorModeSelector.rightAnchor constraintEqualToAnchor:self.view.rightAnchor].active = YES; - [switchLabel.topAnchor constraintEqualToAnchor:self.statusLabel.topAnchor].active = YES; - [switchLabel.rightAnchor constraintEqualToAnchor:self.terrainAnchorSwitch.leftAnchor].active = - YES; + [switchLabel.bottomAnchor constraintEqualToAnchor:self.statusLabel.bottomAnchor].active = YES; + [switchLabel.rightAnchor constraintEqualToAnchor:self.streetscapeGeometrySwitch.leftAnchor] + .active = YES; [switchLabel.heightAnchor constraintEqualToConstant:40].active = YES; [clearAllAnchorsButton.bottomAnchor @@ -384,21 +414,62 @@ - (void)checkLocationPermission { - (void)setErrorStatus:(NSString *)message { self.statusLabel.text = message; - self.addAnchorButton.hidden = YES; self.tapScreenLabel.hidden = YES; self.clearAllAnchorsButton.hidden = YES; } -- (SCNNode *)markerNodeIsTerrainAnchor:(BOOL)isTerrainAnchor { +- (UIMenu *)anchorSettingsMenu { + void (^setAnchorMode)(__kindof UIAction *action) = ^(__kindof UIAction *action) { + if ([action.title isEqualToString:@"Rooftop"]) { + self.anchorMode = AnchorTypeRooftop; + } else if ([action.title isEqualToString:@"Terrain"]) { + self.anchorMode = AnchorTypeTerrain; + } else { + self.anchorMode = AnchorTypeGeospatial; + } + self.anchorModeSelector.menu = [self anchorSettingsMenu]; + }; + + NSArray *menuItems = @[ + [UIAction + actionWithTitle:[NSString stringWithFormat:@"%@%@", + (self.anchorMode == AnchorTypeGeospatial) ? @"✓ " + : @"", + @"Geospatial"] + image:nil + identifier:nil + handler:setAnchorMode], + [UIAction + actionWithTitle:[NSString + stringWithFormat:@"%@%@", + (self.anchorMode == AnchorTypeTerrain) ? @"✓ " : @"", + @"Terrain"] + image:nil + identifier:nil + handler:setAnchorMode], + [UIAction + actionWithTitle:[NSString + stringWithFormat:@"%@%@", + (self.anchorMode == AnchorTypeRooftop) ? @"✓ " : @"", + @"Rooftop"] + image:nil + identifier:nil + handler:setAnchorMode] + + ]; + return [UIMenu menuWithTitle:@"Anchor Type" children:menuItems]; +} + +- (SCNNode *)markerNodeForAnchorType:(AnchorType)anchorType { NSURL *objURL = [[NSBundle mainBundle] URLForResource:@"geospatial_marker" withExtension:@"obj"]; MDLAsset *markerAsset = [[MDLAsset alloc] initWithURL:objURL]; MDLMesh *markerObject = (MDLMesh *)[markerAsset objectAtIndex:0]; MDLMaterial *material = [[MDLMaterial alloc] initWithName:@"baseMaterial" scatteringFunction:[[MDLScatteringFunction alloc] init]]; NSURL *textureURL = - isTerrainAnchor - ? [[NSBundle mainBundle] URLForResource:@"spatial-marker-yellow" withExtension:@"png"] - : [[NSBundle mainBundle] URLForResource:@"spatial-marker-baked" withExtension:@"png"]; + (anchorType == AnchorTypeGeospatial) + ? [[NSBundle mainBundle] URLForResource:@"spatial-marker-baked" withExtension:@"png"] + : [[NSBundle mainBundle] URLForResource:@"spatial-marker-yellow" withExtension:@"png"]; MDLMaterialProperty *materialPropetry = [[MDLMaterialProperty alloc] initWithName:@"texture" semantic:MDLMaterialSemanticBaseColor @@ -434,6 +505,9 @@ - (void)setUpGARSession { GARSessionConfiguration *configuration = [[GARSessionConfiguration alloc] init]; configuration.geospatialMode = GARGeospatialModeEnabled; + configuration.streetscapeGeometryMode = self.isStreetscapeGeometryEnabled + ? GARStreetscapeGeometryModeEnabled + : GARStreetscapeGeometryModeDisabled; [self.garSession setConfiguration:configuration error:&error]; if (error) { [self setErrorStatus:[NSString stringWithFormat:@"Failed to configure GARSession: %d", @@ -468,16 +542,20 @@ - (void)addSavedAnchors { simd_quatf eastUpSouthQTarget = simd_quaternion((simd_float4){savedAnchor[@"x"].floatValue, savedAnchor[@"y"].floatValue, savedAnchor[@"z"].floatValue, savedAnchor[@"w"].floatValue}); - if ([savedAnchor objectForKey:@"altitude"]) { + if (AnchorTypeTerrain == [savedAnchor objectForKey:@"type"].intValue) { + [self addTerrainAnchorWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) + eastUpSouthQTarget:eastUpSouthQTarget + shouldSave:NO]; + } else if (AnchorTypeRooftop == [savedAnchor objectForKey:@"type"].intValue) { + [self addRooftopAnchorWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) + eastUpSouthQTarget:eastUpSouthQTarget + shouldSave:NO]; + } else { CLLocationDistance altitude = savedAnchor[@"altitude"].doubleValue; [self addAnchorWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) altitude:altitude eastUpSouthQTarget:eastUpSouthQTarget shouldSave:NO]; - } else { - [self addTerrainAnchorWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) - eastUpSouthQTarget:eastUpSouthQTarget - shouldSave:NO]; } } } @@ -519,40 +597,79 @@ - (void)updateLocalizationState { } } +- (void)saveAnchor:(CLLocationCoordinate2D)coordinate + eastUpSouthQTarget:(simd_quatf)eastUpSouthQTarget + anchorType:(AnchorType)anchorType + altitude:(CLLocationDistance)altitude { + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSArray *> *savedAnchors = + [defaults arrayForKey:kSavedAnchorsUserDefaultsKey] ?: @[]; + NSMutableArray *> *newSavedAnchors = + [savedAnchors mutableCopy]; + + NSMutableDictionary *anchorProperties = [NSMutableDictionary dictionaryWithDictionary:@{ + @"latitude" : @(coordinate.latitude), + @"longitude" : @(coordinate.longitude), + @"type" : @(anchorType), + @"x" : @(eastUpSouthQTarget.vector[0]), + @"y" : @(eastUpSouthQTarget.vector[1]), + @"z" : @(eastUpSouthQTarget.vector[2]), + @"w" : @(eastUpSouthQTarget.vector[3]), + }]; + + if (anchorType == AnchorTypeGeospatial) { + [anchorProperties setObject:@(altitude) forKey:@"altitude"]; + } + + [newSavedAnchors addObject:anchorProperties]; + [defaults setObject:newSavedAnchors forKey:kSavedAnchorsUserDefaultsKey]; +} + +- (void)addMarkerNode:(GARAnchor *)anchor anchorType:(AnchorType)anchorType { + SCNNode *node = self.markerNodes[anchor.identifier]; + + node = [self markerNodeForAnchorType:anchorType]; + self.markerNodes[anchor.identifier] = node; + [self.scene.rootNode addChildNode:node]; + + [self updateMarkerNode:anchor]; +} + +- (void)updateMarkerNode:(GARAnchor *)anchor { + SCNNode *node = self.markerNodes[anchor.identifier]; + + if (!node) { + return; + } + // Rotate the virtual object 180 degrees around the Y axis to make the object face the GL + // camera -Z axis, since camera Z axis faces toward users. + simd_quatf rotationYquat = simd_quaternion(M_PI, (simd_float3){0, 1, 0}); + node.simdTransform = matrix_multiply(anchor.transform, simd_matrix4x4(rotationYquat)); + node.hidden = (self.localizationState != LocalizationStateLocalized); + + // Scale up anchors which are far from the camera. + SCNNode *cameraPosition = [SCNNode node]; + cameraPosition.simdTransform = self.arSession.currentFrame.camera.transform; + float distance = simd_distance(cameraPosition.simdPosition, node.simdPosition); + float scale = 1.0f + (simd_clamp(distance, 5.0f, 20.0f) - 5.0f) / 15.0f; + node.simdScale = simd_make_float3(scale, scale, scale); +} + - (void)updateMarkerNodes { NSMutableSet *currentAnchorIDs = [NSMutableSet set]; - - // Add/update nodes for tracking anchors. - for (GARAnchor *anchor in self.garFrame.anchors) { - if (anchor.trackingState != GARTrackingStateTracking) { - continue; + @synchronized(self) { + for (GARAnchor *anchor in self.garFrame.anchors) { + [self updateMarkerNode:anchor]; + [currentAnchorIDs addObject:anchor.identifier]; } - SCNNode *node = self.markerNodes[anchor.identifier]; - - if (!node) { - // Only render resolved Terrain anchors and Geospatial anchors. - if (anchor.terrainState == GARTerrainAnchorStateSuccess) { - node = [self markerNodeIsTerrainAnchor:YES]; - } else if (anchor.terrainState == GARTerrainAnchorStateNone) { - node = [self markerNodeIsTerrainAnchor:NO]; + + // Remove nodes for anchors that are no longer tracking. + for (NSUUID *anchorID in self.markerNodes.allKeys) { + if (![currentAnchorIDs containsObject:anchorID]) { + SCNNode *node = self.markerNodes[anchorID]; + [node removeFromParentNode]; + [self.markerNodes removeObjectForKey:anchorID]; } - self.markerNodes[anchor.identifier] = node; - [self.scene.rootNode addChildNode:node]; - } - // Rotate the virtual object 180 degrees around the Y axis to make the object face the GL - // camera -Z axis, since camera Z axis faces toward users. - simd_quatf rotationYquat = simd_quaternion(M_PI, (simd_float3){0, 1, 0}); - node.simdTransform = matrix_multiply(anchor.transform, simd_matrix4x4(rotationYquat)); - node.hidden = (self.localizationState != LocalizationStateLocalized); - [currentAnchorIDs addObject:anchor.identifier]; - } - - // Remove nodes for anchors that are no longer tracking. - for (NSUUID *anchorID in self.markerNodes.allKeys) { - if (![currentAnchorIDs containsObject:anchorID]) { - SCNNode *node = self.markerNodes[anchorID]; - [node removeFromParentNode]; - [self.markerNodes removeObjectForKey:anchorID]; } } } @@ -605,44 +722,19 @@ - (void)updateTrackingLabel { - (void)updateStatusLabelAndButtons { switch (self.localizationState) { case LocalizationStateLocalized: { - [self.terrainAnchorIDToStartTime removeObjectsForKeys:[self.anchorIDsToRemove allObjects]]; - [self.anchorIDsToRemove removeAllObjects]; - NSString *message = nil; - // If there is a new terrain anchor state, show terrain anchor state. - for (GARAnchor *anchor in self.garFrame.anchors) { - if (anchor.terrainState == GARTerrainAnchorStateNone) { - continue; - } - - if (self.terrainAnchorIDToStartTime[anchor.identifier] != nil) { - message = [NSString stringWithFormat:@"Terrain anchor state: %@", - [self terrainStateString:anchor.terrainState]]; - - NSDate *now = [NSDate date]; - if (anchor.terrainState == GARTerrainAnchorStateTaskInProgress) { - if ([now timeIntervalSinceDate:self.terrainAnchorIDToStartTime[anchor.identifier]] >= - kDurationNoTerrainAnchorResult) { - message = @"Still resolving the terrain anchor. Please make sure you\'re " - @"in an area that has VPS coverage."; - [self.anchorIDsToRemove addObject:anchor.identifier]; - } - } else { - // Remove it if task has finished. - [self.anchorIDsToRemove addObject:anchor.identifier]; - } - } - } - if (message != nil) { - self.statusLabel.text = message; + if (self.resolveAnchorErrorMessage != nil) { + self.statusLabel.text = self.resolveAnchorErrorMessage; } else if (self.garFrame.anchors.count == 0) { self.statusLabel.text = kLocalizationComplete; } else if (!self.islastClickedTerrainAnchorButton) { - self.statusLabel.text = - [NSString stringWithFormat:@"Num anchors: %d", (int)self.garFrame.anchors.count]; + self.statusLabel.text = [NSString + stringWithFormat:@"Num anchors: %d/%lu", + (int)self.garFrame.anchors.count + self.activeFutures, kMaxAnchors]; } self.clearAllAnchorsButton.hidden = (self.garFrame.anchors.count == 0); - self.addAnchorButton.hidden = (self.garFrame.anchors.count >= kMaxAnchors); - self.tapScreenLabel.hidden = (self.garFrame.anchors.count >= kMaxAnchors); + self.tapScreenLabel.hidden = + (self.garFrame.anchors.count + self.activeFutures >= kMaxAnchors); + self.anchorModeSelector.hidden = NO; break; } case LocalizationStatePretracking: @@ -650,18 +742,38 @@ - (void)updateStatusLabelAndButtons { break; case LocalizationStateLocalizing: self.statusLabel.text = kLocalizationTip; - self.addAnchorButton.hidden = YES; self.tapScreenLabel.hidden = YES; self.clearAllAnchorsButton.hidden = YES; break; case LocalizationStateFailed: self.statusLabel.text = kLocalizationFailureMessage; - self.addAnchorButton.hidden = YES; self.tapScreenLabel.hidden = YES; self.clearAllAnchorsButton.hidden = YES; + self.anchorModeSelector.hidden = YES; break; } - self.isTerrainAnchorMode = self.terrainAnchorSwitch.isOn; + + if (self.isStreetscapeGeometryEnabled != self.streetscapeGeometrySwitch.isOn) { + self.isStreetscapeGeometryEnabled = self.streetscapeGeometrySwitch.isOn; + NSError *error = nil; + GARSessionConfiguration *configuration = [[GARSessionConfiguration alloc] init]; + configuration.geospatialMode = GARGeospatialModeEnabled; + configuration.streetscapeGeometryMode = self.isStreetscapeGeometryEnabled + ? GARStreetscapeGeometryModeEnabled + : GARStreetscapeGeometryModeDisabled; + [self.garSession setConfiguration:configuration error:&error]; + if (self.isStreetscapeGeometryEnabled) { + self.streetscapeGeometryParentNode.hidden = NO; + } else { + self.streetscapeGeometryParentNode.hidden = YES; + } + } + + for (SCNNode *node in self.planeNodes) { + if (node) { + node.hidden = self.isStreetscapeGeometryEnabled; + } + } } - (NSString *)terrainStateString:(GARTerrainAnchorState)terrainAnchorState { @@ -683,12 +795,113 @@ - (NSString *)terrainStateString:(GARTerrainAnchorState)terrainAnchorState { } } +- (NSString *)rooftopStateString:(GARRooftopAnchorState)rooftopAnchorState { + switch (rooftopAnchorState) { + case GARRooftopAnchorStateNone: + return @"None"; + case GARRooftopAnchorStateSuccess: + return @"Success"; + case GARRooftopAnchorStateErrorInternal: + return @"ErrorInternal"; + case GARRooftopAnchorStateErrorNotAuthorized: + return @"ErrorNotAuthorized"; + case GARRooftopAnchorStateErrorUnsupportedLocation: + return @"UnsupportedLocation"; + default: + return @"Unknown"; + } +} + +- (SCNNode *)streetscapeGeometryToSCNNode:(GARStreetscapeGeometry *)streetscapeGeometry { + GARMesh *mesh = streetscapeGeometry.mesh; + NSData *data = [NSData dataWithBytes:mesh.vertices length:mesh.vertexCount * sizeof(GARVertex)]; + + // Vertices are stored in a packed float array. + SCNGeometrySource *vertices = + [SCNGeometrySource geometrySourceWithData:data + semantic:SCNGeometrySourceSemanticVertex + vectorCount:mesh.vertexCount + floatComponents:YES + componentsPerVector:3 + bytesPerComponent:4 + dataOffset:0 + dataStride:12]; + + NSData *triangleData = [NSData dataWithBytes:mesh.triangles + length:mesh.triangleCount * sizeof(GARIndexTriangle)]; + SCNGeometryElement *indices = + [SCNGeometryElement geometryElementWithData:triangleData + primitiveType:SCNGeometryPrimitiveTypeTriangles + primitiveCount:mesh.triangleCount + bytesPerIndex:4]; + + SCNGeometry *geometry = [SCNGeometry geometryWithSources:@[ vertices ] elements:@[ indices ]]; + + SCNMaterial *material = geometry.materials.firstObject; + if (streetscapeGeometry.type == GARStreetscapeGeometryTypeTerrain) { + material.diffuse.contents = [UIColor colorWithRed:0 green:.5 blue:0 alpha:.7]; + material.doubleSided = NO; + } else { + NSArray *buildingColors = @[ + [UIColor colorWithRed:.7 green:0. blue:.7 alpha:.8], + [UIColor colorWithRed:.7 green:.7 blue:0 alpha:.8], + [UIColor colorWithRed:.0 green:.7 blue:.7 alpha:.8], + ]; + + UIColor *randomColor = buildingColors[arc4random() % buildingColors.count]; + material.diffuse.contents = randomColor; + material.blendMode = SCNBlendModeReplace; + material.doubleSided = NO; + } + + SCNGeometry *lineGeometry = [SCNGeometry geometryWithSources:@[ vertices ] elements:@[ indices ]]; + SCNMaterial *lineMaterial = lineGeometry.materials.firstObject; + lineMaterial.fillMode = SCNFillModeLines; + lineMaterial.diffuse.contents = [UIColor blackColor]; + SCNNode *node = [SCNNode nodeWithGeometry:geometry]; + [node addChildNode:[SCNNode nodeWithGeometry:lineGeometry]]; + return node; +} + +- (void)renderStreetscapeGeometries { + NSArray *streetscapeGeometries = [self.garFrame streetscapeGeometries]; + if (streetscapeGeometries) { + self.streetscapeGeometryParentNode.hidden = + (self.localizationState != LocalizationStateLocalized); + + // Add new streetscapeGeometries which are appearing for the first time. + for (GARStreetscapeGeometry *streetscapeGeometry in streetscapeGeometries) { + NSUUID *identifier = streetscapeGeometry.identifier; + if (![self.streetscapeGeometryNodes objectForKey:identifier]) { + SCNNode *node = [self streetscapeGeometryToSCNNode:streetscapeGeometry]; + [self.streetscapeGeometryNodes setObject:node forKey:identifier]; + [self.streetscapeGeometryParentNode addChildNode:node]; + } + + SCNNode *node = [self.streetscapeGeometryNodes objectForKey:streetscapeGeometry.identifier]; + node.simdTransform = streetscapeGeometry.meshTransform; + + // Hide geometries if not actively tracking. + if (streetscapeGeometry.trackingState == GARTrackingStateTracking) { + node.hidden = NO; + } else if (streetscapeGeometry.trackingState == GARTrackingStatePaused) { + node.hidden = YES; + } else { + // Removed permanently stopped geometries. + [self.streetscapeGeometryNodes[identifier] removeFromParentNode]; + [self.streetscapeGeometryNodes removeObjectForKey:identifier]; + } + } + } +} + - (void)updateWithGARFrame:(GARFrame *)garFrame { self.garFrame = garFrame; [self updateLocalizationState]; [self updateMarkerNodes]; [self updateTrackingLabel]; [self updateStatusLabelAndButtons]; + [self renderStreetscapeGeometries]; } - (void)addAnchorWithCoordinate:(CLLocationCoordinate2D)coordinate @@ -699,92 +912,101 @@ - (void)addAnchorWithCoordinate:(CLLocationCoordinate2D)coordinate // first snapshot of the anchor (which is immutable). Use the updated snapshots in // |GARFrame.anchors| to get updated values on a frame-by-frame basis. NSError *error = nil; - [self.garSession createAnchorWithCoordinate:coordinate - altitude:altitude - eastUpSouthQAnchor:eastUpSouthQTarget - error:&error]; + GARAnchor *anchor = [self.garSession createAnchorWithCoordinate:coordinate + altitude:altitude + eastUpSouthQAnchor:eastUpSouthQTarget + error:&error]; if (error) { NSLog(@"Error adding anchor: %@", error); return; } + [self addMarkerNode:anchor anchorType:AnchorTypeGeospatial]; if (shouldSave) { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSArray *> *savedAnchors = - [defaults arrayForKey:kSavedAnchorsUserDefaultsKey] ?: @[]; - NSMutableArray *> *newSavedAnchors = - [savedAnchors mutableCopy]; - - [newSavedAnchors addObject:@{ - @"latitude" : @(coordinate.latitude), - @"longitude" : @(coordinate.longitude), - @"altitude" : @(altitude), - @"x" : @(eastUpSouthQTarget.vector[0]), - @"y" : @(eastUpSouthQTarget.vector[1]), - @"z" : @(eastUpSouthQTarget.vector[2]), - @"w" : @(eastUpSouthQTarget.vector[3]), - }]; - [defaults setObject:newSavedAnchors forKey:kSavedAnchorsUserDefaultsKey]; + [self saveAnchor:coordinate + eastUpSouthQTarget:eastUpSouthQTarget + anchorType:AnchorTypeGeospatial + altitude:altitude]; } } - (void)addTerrainAnchorWithCoordinate:(CLLocationCoordinate2D)coordinate eastUpSouthQTarget:(simd_quatf)eastUpSouthQTarget shouldSave:(BOOL)shouldSave { - // The return value of |createAnchorWithCoordinate:altitude:eastUpSouthQAnchor:error:| is just the - // first snapshot of the anchor (which is immutable). Use the updated snapshots in - // |GARFrame.anchors| to get updated values on a frame-by-frame basis. NSError *error = nil; - GARAnchor *anchor = [self.garSession createAnchorWithCoordinate:coordinate - altitudeAboveTerrain:0 - eastUpSouthQAnchor:eastUpSouthQTarget - error:&error]; + [self.garSession + createAnchorWithCoordinate:coordinate + altitudeAboveTerrain:0 + eastUpSouthQAnchor:eastUpSouthQTarget + completionHandler:^void(GARAnchor *anchor, GARTerrainAnchorState state) { + if (state != GARTerrainAnchorStateSuccess) { + self.resolveAnchorErrorMessage = + [NSString stringWithFormat:@"Error resolving terrain anchor: %@", + [self terrainStateString:state]]; + } else { + self.activeFutures--; + [self addMarkerNode:anchor anchorType:AnchorTypeTerrain]; + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + if (shouldSave) { + [self saveAnchor:coordinate + eastUpSouthQTarget:eastUpSouthQTarget + anchorType:AnchorTypeTerrain + altitude:-1.0]; + } + }); + } + } + error:&error]; + if (error) { NSLog(@"Error adding anchor: %@", error); if (error.code == GARSessionErrorCodeResourceExhausted) { - self.statusLabel.text = - @"Too many terrain anchors have already been held. Clear all anchors to create new ones."; + self.statusLabel.text = @"Too many terrain and rooftop anchors have already been held. Clear " + @"all anchors to create new ones."; } return; } - self.terrainAnchorIDToStartTime[anchor.identifier] = [NSDate date]; - if (shouldSave) { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSArray *> *savedAnchors = - [defaults arrayForKey:kSavedAnchorsUserDefaultsKey] ?: @[]; - NSMutableArray *> *newSavedAnchors = - [savedAnchors mutableCopy]; - [newSavedAnchors addObject:@{ - @"latitude" : @(coordinate.latitude), - @"longitude" : @(coordinate.longitude), - @"x" : @(eastUpSouthQTarget.vector[0]), - @"y" : @(eastUpSouthQTarget.vector[1]), - @"z" : @(eastUpSouthQTarget.vector[2]), - @"w" : @(eastUpSouthQTarget.vector[3]), - }]; - [defaults setObject:newSavedAnchors forKey:kSavedAnchorsUserDefaultsKey]; - } -} - -- (void)addAnchorButtonPressed { - // This button will be hidden if not currently tracking, so this can't be nil. - GARGeospatialTransform *geospatialTransform = self.garFrame.earth.cameraGeospatialTransform; - // Update the quaternion from landscape orientation to portrait orientation. - simd_quatf rotationZquat = simd_quaternion(M_PI / 2, (simd_float3){0, 0, 1}); - simd_quatf eastUpSouthQPortraitCamera = - simd_mul(geospatialTransform.eastUpSouthQTarget, rotationZquat); - - if (self.isTerrainAnchorMode) { - [self addTerrainAnchorWithCoordinate:geospatialTransform.coordinate - eastUpSouthQTarget:eastUpSouthQPortraitCamera - shouldSave:YES]; - } else { - [self addAnchorWithCoordinate:geospatialTransform.coordinate - altitude:geospatialTransform.altitude - eastUpSouthQTarget:eastUpSouthQPortraitCamera - shouldSave:YES]; + self.activeFutures++; +} + +- (void)addRooftopAnchorWithCoordinate:(CLLocationCoordinate2D)coordinate + eastUpSouthQTarget:(simd_quatf)eastUpSouthQTarget + shouldSave:(BOOL)shouldSave { + NSError *error = nil; + [self.garSession + createAnchorWithCoordinate:coordinate + altitudeAboveRooftop:0 + eastUpSouthQAnchor:eastUpSouthQTarget + completionHandler:^void(GARAnchor *anchor, GARRooftopAnchorState state) { + self.activeFutures--; + if (state != GARRooftopAnchorStateSuccess) { + self.resolveAnchorErrorMessage = + [NSString stringWithFormat:@"Error resolving rooftop anchor: %@", + [self rooftopStateString:state]]; + } else { + [self addMarkerNode:anchor anchorType:AnchorTypeRooftop]; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + if (shouldSave) { + [self saveAnchor:coordinate + eastUpSouthQTarget:eastUpSouthQTarget + anchorType:AnchorTypeRooftop + altitude:-1.0]; + } + }); + } + } + error:&error]; + + if (error) { + NSLog(@"Error adding anchor: %@", error); + if (error.code == GARSessionErrorCodeResourceExhausted) { + self.statusLabel.text = @"Too many terrain and rooftop anchors have already been held. Clear " + @"all anchors to create new ones."; + } + return; } - self.islastClickedTerrainAnchorButton = self.isTerrainAnchorMode; + self.activeFutures++; } - (void)clearAllAnchorsButtonPressed { @@ -803,20 +1025,75 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { if (touches.count < 1) { return; } - if (self.garFrame.anchors.count >= kMaxAnchors) { + if (self.garFrame.anchors.count + self.activeFutures >= kMaxAnchors) { return; } + NSError *error = nil; UITouch *touch = [[touches allObjects] firstObject]; CGPoint touchLocation = [touch locationInView:self.scnView]; - NSArray *rayCastResults = [self.arSession - raycast:[self.scnView raycastQueryFromPoint:touchLocation - allowingTarget:ARRaycastTargetExistingPlaneGeometry - alignment:ARRaycastTargetAlignmentHorizontal]]; + ARRaycastQuery *raycastQuery = + [self.scnView raycastQueryFromPoint:touchLocation + allowingTarget:ARRaycastTargetExistingPlaneGeometry + alignment:ARRaycastTargetAlignmentHorizontal]; + + if (self.streetscapeGeometrySwitch.isOn) { + NSArray *results = + [self.garSession raycastStreetscapeGeometry:raycastQuery.origin + direction:raycastQuery.direction + error:&error]; + if (error) { + NSLog(@"Error raycasting StreetscapeGeometry: %@", error); + return; + } + + if (results.count == 0) { + return; + } + GARStreetscapeGeometryRaycastResult *result = results[0]; + GARGeospatialTransform *geospatialTransform = + [self.garSession geospatialTransformFromTransform:result.worldTransform error:&error]; + if (error) { + NSLog(@"Error adding convert transform to GARGeospatialTransform: %@", error); + return; + } + + switch (self.anchorMode) { + case AnchorTypeGeospatial: { + GARAnchor *anchor = + [self.garSession createAnchorOnStreetscapeGeometry:result.streetscapeGeometry + transform:result.worldTransform + error:&error]; + if (error) { + NSLog(@"Error adding streetscape geometry anchor: %@", error); + return; + } + // Don't save anchors on StreetscapeGeometry between sessions. + [self addMarkerNode:anchor anchorType:AnchorTypeGeospatial]; + return; + } + case AnchorTypeTerrain: + // Terrain anchors will be positioned using both the Streetscape Geometry terrain data as + // well as any local ARKit planes, and may appear in a different location to geospatial + // anchors placed at the same location on the terrain mesh. + [self addTerrainAnchorWithCoordinate:geospatialTransform.coordinate + eastUpSouthQTarget:simd_quaternion(0.0f, 0.0f, 0.0f, 1.0f) + shouldSave:YES]; + return; + case AnchorTypeRooftop: + [self addRooftopAnchorWithCoordinate:geospatialTransform.coordinate + eastUpSouthQTarget:simd_quaternion(0.0f, 0.0f, 0.0f, 1.0f) + shouldSave:YES]; + return; + } + + } else { + NSArray *rayCastResults = [self.arSession raycast:raycastQuery]; + if (rayCastResults.count == 0) { + return; + } - if (rayCastResults.count > 0) { ARRaycastResult *result = rayCastResults.firstObject; - NSError *error = nil; GARGeospatialTransform *geospatialTransform = [self.garSession geospatialTransformFromTransform:result.worldTransform error:&error]; if (error) { @@ -824,17 +1101,24 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { return; } - if (self.isTerrainAnchorMode) { - [self addTerrainAnchorWithCoordinate:geospatialTransform.coordinate - eastUpSouthQTarget:geospatialTransform.eastUpSouthQTarget - shouldSave:YES]; - } else { - [self addAnchorWithCoordinate:geospatialTransform.coordinate - altitude:geospatialTransform.altitude - eastUpSouthQTarget:geospatialTransform.eastUpSouthQTarget - shouldSave:YES]; + switch (self.anchorMode) { + case AnchorTypeGeospatial: + [self addAnchorWithCoordinate:geospatialTransform.coordinate + altitude:geospatialTransform.altitude + eastUpSouthQTarget:geospatialTransform.eastUpSouthQTarget + shouldSave:YES]; + return; + case AnchorTypeTerrain: + [self addTerrainAnchorWithCoordinate:geospatialTransform.coordinate + eastUpSouthQTarget:geospatialTransform.eastUpSouthQTarget + shouldSave:YES]; + return; + case AnchorTypeRooftop: + [self addRooftopAnchorWithCoordinate:geospatialTransform.coordinate + eastUpSouthQTarget:geospatialTransform.eastUpSouthQTarget + shouldSave:YES]; + return; } - self.islastClickedTerrainAnchorButton = self.isTerrainAnchorMode; } } @@ -861,14 +1145,10 @@ - (void)locationManager:(CLLocationManager *)locationManager } - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { - NSLog(@"Error get location: %@", error); + NSLog(@"Error get location: %@", error); } #pragma mark - ARSCNViewDelegate -- (nullable SCNNode *)renderer:(id)renderer nodeForAnchor:(ARAnchor *)anchor { - return [[SCNNode alloc] init]; -} - - (void)renderer:(id)renderer didAddNode:(SCNNode *)node forAnchor:(ARAnchor *)anchor { @@ -885,12 +1165,13 @@ - (void)renderer:(id)renderer SCNNode *planeNode = [SCNNode nodeWithGeometry:planeGeometry]; [node addChildNode:planeNode]; + [self.planeNodes addObject:planeNode]; } } - (void)renderer:(id)renderer - didUpdateNode:(SCNNode *)node - forAnchor:(ARAnchor *)anchor { + didUpdateNode:(SCNNode *)node + forAnchor:(ARAnchor *)anchor { if ([anchor isKindOfClass:[ARPlaneAnchor class]]) { ARPlaneAnchor *planeAnchor = (ARPlaneAnchor *)anchor; @@ -900,11 +1181,12 @@ - (void)renderer:(id)renderer } - (void)renderer:(id)renderer - didRemoveNode:(SCNNode *)node - forAnchor:(ARAnchor *)anchor { + didRemoveNode:(SCNNode *)node + forAnchor:(ARAnchor *)anchor { if ([anchor isKindOfClass:[ARPlaneAnchor class]]) { SCNNode *planeNode = node.childNodes.firstObject; [planeNode removeFromParentNode]; + [self.planeNodes removeObject:planeNode]; } } diff --git a/Examples/GeospatialExample/Podfile b/Examples/GeospatialExample/Podfile index cd37b61..a332ce5 100644 --- a/Examples/GeospatialExample/Podfile +++ b/Examples/GeospatialExample/Podfile @@ -1,4 +1,4 @@ target 'GeospatialExample' use_frameworks! platform :ios, '11.0' -pod 'ARCore/Geospatial', '~> 1.36.0' +pod 'ARCore/Geospatial', '~> 1.37.0' diff --git a/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/CloudAnchorManager.h b/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/CloudAnchorManager.h index be955b5..29b18bf 100644 --- a/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/CloudAnchorManager.h +++ b/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/CloudAnchorManager.h @@ -20,8 +20,11 @@ @class CloudAnchorManager; @class GARAnchor; @class GARFrame; +@class GARHostCloudAnchorFuture; +@class GARResolveCloudAnchorFuture; @class GARSession; -@protocol GARSessionDelegate; + +typedef NS_ENUM(NSInteger, GARCloudAnchorState); NS_ASSUME_NONNULL_BEGIN @@ -29,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN * Delegate for receiving callbacks from a CloudAnchorManager and the underlying GARSession. All * methods are optional. */ -@protocol CloudAnchorManagerDelegate +@protocol CloudAnchorManagerDelegate @required /** @@ -57,7 +60,7 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CloudAnchorManager : NSObject -@property(nonatomic, weak, setter=setDelegate:) id delegate; +@property(nonatomic, weak) id delegate; /** * Initialize an instance of CloudAnchorManager. @@ -70,11 +73,15 @@ NS_ASSUME_NONNULL_BEGIN * Host a Cloud Anchor corresponding to the given ARAnchor. * * @param arAnchor An ARAnchor object to be hosted within the hotspot generated by the session. - * @param error A return address which an error will be written to, if one occurs. + * @param completion Callback to invoke when the anchor has finished hosting. + * @param error A return address which an error will be written to, if one occurs. * - * @return The new GARAnchor, or `nil` if there is an error. + * @return The hosting future, or `nil` if there is an error. */ -- (GARAnchor *)hostCloudAnchor:(ARAnchor *)arAnchor error:(NSError **)error; +- (GARHostCloudAnchorFuture *)hostCloudAnchor:(ARAnchor *)arAnchor + completion:(void (^)(NSString *_Nullable, + GARCloudAnchorState))completion + error:(NSError **)error; /** * Attempt to resolve the last hosted anchor for the given anchor ids. If there is a cloud anchor @@ -82,12 +89,15 @@ NS_ASSUME_NONNULL_BEGIN * resolved. * * @param anchorId Anchor cloud identifier. - * @param error A return address which an error will be written to, if one occurs. + * @param completion Callback to invoke when the anchor has finished resolving. + * @param error A return address which an error will be written to, if one occurs. * * @return The new GARAnchor, or `nil` if there is an error. */ -- (GARAnchor *)resolveAnchorWithAnchorId:(NSString *)anchorId error:(NSError **)error; - +- (GARResolveCloudAnchorFuture *)resolveAnchorWithAnchorId:(NSString *)anchorId + completion:(void (^)(GARAnchor *_Nullable, + GARCloudAnchorState))completion + error:(NSError **)error; /** * Remove the passed GARAnchor from the underlying GARSession * diff --git a/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/CloudAnchorManager.m b/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/CloudAnchorManager.m index 9d2225e..ffdc728 100644 --- a/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/CloudAnchorManager.m +++ b/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/CloudAnchorManager.m @@ -49,11 +49,6 @@ - (instancetype)initWithARSession:(id)session { return self; } -- (void)setDelegate:(id)delegate { - _delegate = delegate; - self.gSession.delegate = delegate; -} - #pragma mark - ARSessionDelegate - (void)session:(ARSession *)session didUpdateFrame:(ARFrame *)frame { @@ -84,20 +79,26 @@ - (int)getFeatureMapQuality:(ARFrame *)frame { #pragma mark - Public -- (GARAnchor *)hostCloudAnchor:(ARAnchor *)arAnchor error:(NSError **)error { - // To share an anchor, we call host anchor here on the ARCore session. - // session:didHostAnchor: session:didFailToHostAnchor: will get called appropriately. - // Creating a Cloud Anchor with lifetime = 1 day. This is configurable up to 365 days. +- (GARHostCloudAnchorFuture *)hostCloudAnchor:(ARAnchor *)arAnchor + completion:(void (^)(NSString *, GARCloudAnchorState))completion + error:(NSError **)error { + // Creating a Cloud Anchor with lifetime = 1 day. This is configurable up to 365 days. // If you want TTL > 1, please use the constructor sessionWithError: and use setAuthToken:. // Details can be found in // https://developers.google.com/ar/develop/ios/persistent-cloud-anchors - return [self.gSession hostCloudAnchor:arAnchor TTLDays:1 error:error]; + return [self.gSession hostCloudAnchor:arAnchor + TTLDays:1 + completionHandler:completion + error:error]; } -- (GARAnchor *)resolveAnchorWithAnchorId:(NSString *)anchorId error:(NSError **)error { - // To resolve an anchor, we call resolve anchor here on the ARCore session. - // session:didResolveAnchor: session:didFailToResolveAnchor: will get called appropriately. - return [self.gSession resolveCloudAnchorWithIdentifier:anchorId error:error]; +- (GARResolveCloudAnchorFuture *)resolveAnchorWithAnchorId:(NSString *)anchorId + completion:(void (^)(GARAnchor *_Nullable, + GARCloudAnchorState))completion + error:(NSError **)error { + return [self.gSession resolveCloudAnchorWithIdentifier:anchorId + completionHandler:completion + error:error]; } - (void)removeAnchor:(GARAnchor *)anchor { diff --git a/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/HostViewController.h b/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/HostViewController.h index 95deb5a..421c123 100644 --- a/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/HostViewController.h +++ b/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/HostViewController.h @@ -42,7 +42,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, strong) IBOutlet UILabel *debugLabel; // Local anchor created by hitTest. @property(nonatomic, strong, nullable) ARAnchor *arAnchor; -@property(nonatomic, strong, nullable) GARAnchor *garAnchor; +@property(nonatomic, strong, nullable) GARHostCloudAnchorFuture *hostFuture; @property(nonatomic, assign) HostState state; @property(nonatomic, strong) NSString *cloudAnchorId; @property(nonatomic, strong) NSString *message; diff --git a/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/HostViewController.m b/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/HostViewController.m index b3bd0ff..ff1d626 100644 --- a/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/HostViewController.m +++ b/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/HostViewController.m @@ -27,7 +27,7 @@ static int const kSecToMilliseconds = 1000; static NSString *const kDebugMessagePrefix = @"Debug panel\n"; -@interface HostViewController () +@interface HostViewController () @property(nonatomic) NSMutableArray *qualityBars; @property(nonatomic) FeatureMapQualityBars *featureMapQualityBars; @@ -139,9 +139,14 @@ - (void)enterState:(HostState)state { break; case HostStateFinished: self.message = [NSString - stringWithFormat:@"Finished: %@", [self cloudStateString:self.garAnchor.cloudState]]; - self.debugMessage = - [NSString stringWithFormat:@"Anchor %@ created", self.garAnchor.cloudIdentifier]; + stringWithFormat:@"Finished: %@", + [self cloudStateString:self.hostFuture.resultCloudAnchorState]]; + if (self.hostFuture.resultCloudIdentifier) { + self.debugMessage = + [NSString stringWithFormat:@"Anchor %@ created", self.hostFuture.resultCloudIdentifier]; + } else { + self.debugMessage = @"Anchor failed to host"; + } break; } self.state = state; @@ -214,6 +219,15 @@ - (SCNNode *)cloudAnchorNode { #pragma mark - CloudAnchorManagerDelegate +- (void)handleHostAnchor:(NSString *)anchorId cloudState:(GARCloudAnchorState)cloudState { + if (cloudState == GARCloudAnchorStateSuccess) { + double durationSec = [[NSDate date] timeIntervalSinceDate:self.hostBeginDate]; + NSLog(@"Time taken to complete hosting process: %f ms", durationSec * kSecToMilliseconds); + [self sendSaveAlert:anchorId]; + } + [self enterState:HostStateFinished]; +} + - (void)cloudAnchorManager:(CloudAnchorManager *)manager didUpdateFrame:(GARFrame *)garFrame tracking:(BOOL)tracking @@ -229,7 +243,13 @@ - (void)cloudAnchorManager:(CloudAnchorManager *)manager float avg = [self.featureMapQualityBars featureMapQualityAvg]; NSLog(@"History of average mapping quality calls: %f", avg); if (avg > kFeatureMapQualityThreshold) { - self.garAnchor = [self.cloudAnchorManager hostCloudAnchor:self.arAnchor error:nil]; + __weak HostViewController *weakSelf = self; + self.hostFuture = [self.cloudAnchorManager + hostCloudAnchor:self.arAnchor + completion:^(NSString *anchorId, GARCloudAnchorState cloudState) { + [weakSelf handleHostAnchor:anchorId cloudState:cloudState]; + } + error:nil]; [self enterState:HostStateHosting]; self.hostBeginDate = [NSDate date]; return; @@ -315,20 +335,4 @@ - (void)renderer:(id)renderer [planeNode removeFromParentNode]; } } - -#pragma mark - GARSessionDelegate - -- (void)session:(GARSession *)session didHostAnchor:(GARAnchor *)anchor { - self.garAnchor = anchor; - [self enterState:HostStateFinished]; - double durationSec = [[NSDate date] timeIntervalSinceDate:self.hostBeginDate]; - NSLog(@"Time taken to complete hosting process: %f ms", durationSec * kSecToMilliseconds); - [self sendSaveAlert:anchor.cloudIdentifier]; -} - -- (void)session:(GARSession *)session didFailToHostAnchor:(GARAnchor *)anchor { - self.garAnchor = anchor; - [self enterState:HostStateFinished]; -} - @end diff --git a/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/ResolveViewController.m b/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/ResolveViewController.m index 8d0ba60..3bfce4d 100644 --- a/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/ResolveViewController.m +++ b/Examples/PersistentCloudAnchorExample/PersistentCloudAnchorExample/ResolveViewController.m @@ -18,13 +18,12 @@ static NSString *const kDebugMessagePrefix = @"Debug panel\n"; -@interface ResolveViewController () +@interface ResolveViewController () // Nodes representing resolved GARAnchors. Updated when anchor changes. -@property(nonatomic, strong) NSMutableDictionary *idToResolvedAnchorNodes; -@property(nonatomic, strong) NSMutableDictionary *idToGarAnchors; +@property(nonatomic, strong) NSMutableDictionary *idToResolvedAnchorNodes; +@property(nonatomic, strong) + NSMutableDictionary *idToFutures; @end @@ -34,7 +33,7 @@ @implementation ResolveViewController - (void)initProperty { _idToResolvedAnchorNodes = [NSMutableDictionary dictionary]; - _idToGarAnchors = [NSMutableDictionary dictionary]; + _idToFutures = [NSMutableDictionary dictionary]; } - (void)viewDidLoad { @@ -53,12 +52,39 @@ - (void)viewDidLoad { #pragma mark - Anchor Resolving +- (void)handleResolveAnchor:(GARAnchor *)anchor + cloudState:(GARCloudAnchorState)cloudState + anchorId:(NSString *)anchorId { + if (self.state != ResolveStateResolving || ![self.idToFutures objectForKey:anchorId]) { + return; + } + + if (cloudState == GARCloudAnchorStateSuccess) { + SCNNode *node = [self cloudAnchorNode]; + node.simdTransform = anchor.transform; + [self.sceneView.scene.rootNode addChildNode:node]; + self.idToResolvedAnchorNodes[anchor.identifier] = node; + self.debugMessage = [NSString + stringWithFormat:@"Resolved %@ continuing to refine pose.", + [[self.idToResolvedAnchorNodes allKeys] componentsJoinedByString:@", "]]; + [self updateMessageLabel]; + } + [self updateResolveStatus]; +} + // Encourage the user to look at a previously mapped area. - (void)resolveAnchors:(NSArray *)anchorIds { [self enterState:ResolveStateResolving]; + __weak ResolveViewController *weakSelf = self; for (NSString *anchorId in anchorIds) { - self.idToGarAnchors[anchorId] = [self.cloudAnchorManager resolveAnchorWithAnchorId:anchorId - error:nil]; + self.idToFutures[anchorId] = [self.cloudAnchorManager + resolveAnchorWithAnchorId:anchorId + completion:^(GARAnchor *anchor, GARCloudAnchorState cloudState) { + [weakSelf handleResolveAnchor:anchor + cloudState:cloudState + anchorId:anchorId]; + } + error:nil]; } } @@ -91,12 +117,12 @@ - (void)enterState:(ResolveState)state { case ResolveStateFinished: self.message = [NSString stringWithFormat:@"Resolve Finished: \n"]; - for (NSString *anchorId in [self.idToGarAnchors allKeys]) { + for (NSString *anchorId in [self.idToFutures allKeys]) { self.message = [self.message stringByAppendingString: [NSString - stringWithFormat:@"%@ ", [self cloudStateString:self.idToGarAnchors[anchorId] - .cloudState]]]; + stringWithFormat:@"%@ ", [self cloudStateString:self.idToFutures[anchorId] + .resultCloudAnchorState]]]; } self.debugMessage = [NSString stringWithFormat: @@ -142,9 +168,8 @@ - (SCNNode *)cloudAnchorNode { - (void)updateResolveStatus { BOOL allFinished = YES; - for (NSString *anchorId in [self.idToGarAnchors allKeys]) { - if (self.idToGarAnchors[anchorId].cloudState == GARCloudAnchorStateNone || - self.idToGarAnchors[anchorId].cloudState == GARCloudAnchorStateTaskInProgress) { + for (NSString *anchorId in [self.idToFutures allKeys]) { + if (self.idToFutures[anchorId].state == GARFutureStatePending) { allFinished = NO; break; } @@ -164,10 +189,9 @@ - (void)cloudAnchorManager:(CloudAnchorManager *)manager featureMapQuality:(int)featureMapQuality { if (self.state == ResolveStateResolving) { for (GARAnchor *garAnchor in garFrame.updatedAnchors) { - if ([self.idToResolvedAnchorNodes objectForKey:garAnchor.cloudIdentifier]) { - self.idToResolvedAnchorNodes[garAnchor.cloudIdentifier].simdTransform = garAnchor.transform; - self.idToResolvedAnchorNodes[garAnchor.cloudIdentifier].hidden = - !garAnchor.hasValidTransform; + if ([self.idToResolvedAnchorNodes objectForKey:garAnchor.identifier]) { + self.idToResolvedAnchorNodes[garAnchor.identifier].simdTransform = garAnchor.transform; + self.idToResolvedAnchorNodes[garAnchor.identifier].hidden = !garAnchor.hasValidTransform; } } } @@ -183,32 +207,4 @@ - (SCNNode *)renderer:(id)renderer nodeForAnchor:(ARAnchor *)a } } -#pragma mark - GARSessionDelegate - -- (void)session:(GARSession *)session didResolveAnchor:(GARAnchor *)anchor { - if (self.state != ResolveStateResolving || - ![self.idToGarAnchors objectForKey:anchor.cloudIdentifier]) { - return; - } - self.idToGarAnchors[anchor.cloudIdentifier] = anchor; - SCNNode *node = [self cloudAnchorNode]; - node.simdTransform = anchor.transform; - [self.sceneView.scene.rootNode addChildNode:node]; - self.idToResolvedAnchorNodes[anchor.cloudIdentifier] = node; - self.debugMessage = [NSString - stringWithFormat:@"Resolved %@ continuing to refine pose.", - [[self.idToResolvedAnchorNodes allKeys] componentsJoinedByString:@", "]]; - [self updateMessageLabel]; - [self updateResolveStatus]; -} - -- (void)session:(GARSession *)session didFailToResolveAnchor:(GARAnchor *)anchor { - if (self.state != ResolveStateResolving || - ![self.idToGarAnchors objectForKey:anchor.cloudIdentifier]) { - return; - } - self.idToGarAnchors[anchor.cloudIdentifier] = anchor; - [self updateResolveStatus]; -} - @end diff --git a/Examples/PersistentCloudAnchorExample/Podfile b/Examples/PersistentCloudAnchorExample/Podfile index a88c3e1..93ded7b 100644 --- a/Examples/PersistentCloudAnchorExample/Podfile +++ b/Examples/PersistentCloudAnchorExample/Podfile @@ -1,4 +1,4 @@ target 'PersistentCloudAnchorExample' use_frameworks! platform :ios, '11.0' -pod 'ARCore/CloudAnchors', '~> 1.36.0' +pod 'ARCore/CloudAnchors', '~> 1.37.0' diff --git a/LICENSE b/LICENSE index f64e55b..3953d69 100644 --- a/LICENSE +++ b/LICENSE @@ -431,6 +431,8 @@ THE SOFTWARE. This software is partially based on Closure Library: +Files: all except mochikit/async/deferred{,list}.js + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -610,7 +612,7 @@ This software is partially based on Closure Library: ------------------ -Files: third_party/closure/goog/mochikit/async/deferred{,list}.js +Files: mochikit/async/deferred{,list}.js MIT License =========== @@ -5797,6 +5799,23 @@ This software is partially based on MediaPipe: See the License for the specific language governing permissions and limitations under the License. +=========================================================================== +For files under tasks/cc/text/language_detector/custom_ops/utils/utf/ +=========================================================================== +/* + * The authors of this software are Rob Pike and Ken Thompson. + * Copyright (c) 2002 by Lucent Technologies. + * Permission to use, copy, modify, and distribute this software for any + * purpose without fee is hereby granted, provided that this entire notice + * is included in all copies of any software which is or includes a copy + * or modification of this software and in all copies of the supporting + * documentation for such software. + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY + * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. + */ + This software is partially based on NCurses: Copyright (c) 1998-2017,2018 Free Software Foundation, Inc. @@ -9339,6 +9358,56 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Copyright (c) 2003 Thomas Klausner. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +divsufsort.c for libdivsufsort-lite +Copyright (c) 2003-2008 Yuta Mori All Rights Reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + This software is partially based on c-ares: # c-ares license @@ -10711,6 +10780,32 @@ SUCH DAMAGE. $Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $ +This software is partially based on libf2c: + +/**************************************************************** +Copyright 1990 - 1997 by AT&T, Lucent Technologies and Bellcore. + +Permission to use, copy, modify, and distribute this software +and its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the names of AT&T, Bell Laboratories, +Lucent or Bellcore or any of their entities not be used in +advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +AT&T, Lucent and Bellcore disclaim all warranties with regard to +this software, including all implied warranties of +merchantability and fitness. In no event shall AT&T, Lucent or +Bellcore be liable for any special, indirect or consequential +damages or any damages whatsoever resulting from loss of use, +data or profits, whether in an action of contract, negligence or +other tortious action, arising out of or in connection with the +use or performance of this software. +****************************************************************/ + + This software is partially based on libjpeg-turbo: For a summary of these license terms for the main libjpeg-turbo code, see @@ -10862,8 +10957,6 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. This software is partially based on libwebp: -Files: v0_2/* - Copyright 2010 Google LLC Redistribution and use in source and binary forms, with or without @@ -10920,36 +11013,632 @@ litigation is filed. -------------------------------------------------------------------------------- -Files: v0_2/m4/ax_pthread.m4 +Files: m4/ax_pthread.m4 Copyright (c) 2008 Steven G. Johnson Copyright (c) 2011 Daniel Richard G. -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation, either version 3 of the License, or (at your -option) any later version. + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. -You should have received a copy of the GNU General Public License along -with this program. If not, see . + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. -As a special exception, the respective Autoconf Macro's copyright owner -gives unlimited permission to copy, distribute and modify the configure -scripts that are the output of Autoconf when processing the Macro. You -need not follow the terms of the GNU General Public License when using -or distributing such scripts, even though portions of the text of the -Macro appear in them. The GNU General Public License (GPL) does govern -all other use of the material that constitutes the Autoconf Macro. + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. -This special exception to the GPL applies to versions of the Autoconf -Macro released by the Autoconf Archive. When you make and distribute a -modified version of the Autoconf Macro, you may extend this special -exception to the GPL to apply to your modified version as well. + END OF TERMS AND CONDITIONS AUTOCONF CONFIGURE SCRIPT EXCEPTION @@ -11547,7 +12236,7 @@ This software is partially based on program_image_remapper: Apache License Version 2.0, January 2004 - https://www.apache.org/licenses/ + http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION @@ -11739,7 +12428,7 @@ This software is partially based on program_image_remapper: you may not use this file except in compliance with the License. You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/Package.swift b/Package.swift index 3776ae0..9404e2c 100644 --- a/Package.swift +++ b/Package.swift @@ -34,8 +34,8 @@ let package = Package( ], targets: [ .binaryTarget( - name: "ARCoreBase", url: "https://dl.google.com/arcore/swiftpm/1.36.0/Base.zip", - checksum: "ce56efd4a30e0d65d95459fc4cd1ad186b56bb179095423400a4bd5ada807f85" + name: "ARCoreBase", url: "https://dl.google.com/arcore/swiftpm/1.37.0/Base.zip", + checksum: "818886f60830c504f71914705b4bf173db4cce8bc6f90fd02217948d1e3096dd" ), .target( name: "Base", @@ -50,8 +50,8 @@ let package = Package( ), .binaryTarget( name: "ARCoreCloudAnchors", - url: "https://dl.google.com/arcore/swiftpm/1.36.0/CloudAnchors.zip", - checksum: "548d25b408f9c21a5b20de64fd570a06e69c16fed10dea326ff045980ffee64d" + url: "https://dl.google.com/arcore/swiftpm/1.37.0/CloudAnchors.zip", + checksum: "1b711920baaee575d397bdc6671bc37650ba64ad1ef310f8f046ab2f574dccb1" ), .target( name: "CloudAnchors", @@ -66,8 +66,8 @@ let package = Package( publicHeadersPath: "Sources" ), .binaryTarget( - name: "ARCoreGeospatial", url: "https://dl.google.com/arcore/swiftpm/1.36.0/Geospatial.zip", - checksum: "ee88f56df2c154f32a5bcb5c63208fef0ab021a83de7bb89208cbc5f193e20e7" + name: "ARCoreGeospatial", url: "https://dl.google.com/arcore/swiftpm/1.37.0/Geospatial.zip", + checksum: "02c59bc26fc051626bcc7a4493682e0ecd743b2d2bd06eccb1a7c54001ae81c7" ), .target( name: "Geospatial", @@ -80,8 +80,8 @@ let package = Package( publicHeadersPath: "Sources" ), .binaryTarget( - name: "ARCoreGARSession", url: "https://dl.google.com/arcore/swiftpm/1.36.0/GARSession.zip", - checksum: "08b63e5d454a0063fbbe3102d09ec85a0c55426a1045dbf0cf5624aef9274e77" + name: "ARCoreGARSession", url: "https://dl.google.com/arcore/swiftpm/1.37.0/GARSession.zip", + checksum: "2f51ef1960406cabe29e782bdc6006885b4d4c17eef8a1a414eadff881fcf5d1" ), .target( name: "GARSession", @@ -90,7 +90,6 @@ let package = Package( "Base", .product(name: "nanopb", package: "nanopb"), .product(name: "FirebaseRemoteConfig", package: "firebase-ios-sdk"), - .product(name: "GoogleDataTransport", package: "GoogleDataTransport"), ], path: "GARSession", sources: ["dummy.m"], @@ -99,8 +98,8 @@ let package = Package( ), .binaryTarget( name: "ARCoreAugmentedFaces", - url: "https://dl.google.com/arcore/swiftpm/1.36.0/AugmentedFaces.zip", - checksum: "802d2c057b2a02d912db1d2450bdc70856e49b2fbf9eba2c7b8beb51f7cd1196" + url: "https://dl.google.com/arcore/swiftpm/1.37.0/AugmentedFaces.zip", + checksum: "36f7af3e75bc006f609f4ab4183c6399c76fb3d218bba748786b791a2243b8c6" ), .target( name: "AugmentedFaces", @@ -108,7 +107,6 @@ let package = Package( "ARCoreAugmentedFaces", "Base", .product(name: "nanopb", package: "nanopb"), - .product(name: "GoogleDataTransport", package: "GoogleDataTransport"), ], path: "AugmentedFaces", sources: ["dummy.m"],