Skip to content

Commit e78b797

Browse files
authored
Merge pull request #90 from panter/feature-points
small fix for featurepoints
2 parents 3b8456b + aea7a5a commit e78b797

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

ios/RCTARKit.m

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -435,26 +435,28 @@ - (void)session:(ARSession *)session didUpdateFrame:(ARFrame *)frame {
435435
}
436436
}
437437
if (self.onFeaturesDetected) {
438+
NSMutableArray * featurePoints = [NSMutableArray array];
439+
for (int i = 0; i < frame.rawFeaturePoints.count; i++) {
440+
vector_float3 point = frame.rawFeaturePoints.points[i];
441+
442+
NSString * pointId = [NSString stringWithFormat:@"featurepoint_%lld",frame.rawFeaturePoints.identifiers[i]];
443+
444+
[featurePoints addObject:@{
445+
@"x": @(point[0]),
446+
@"y": @(point[1]),
447+
@"z": @(point[2]),
448+
@"id":pointId,
449+
}];
450+
451+
}
438452
dispatch_async(dispatch_get_main_queue(), ^{
439453

440-
NSMutableArray * featurePoints = [NSMutableArray array];
441-
for (int i = 0; i < frame.rawFeaturePoints.count; i++) {
442-
vector_float3 point = frame.rawFeaturePoints.points[i];
443-
444-
NSString * pointId = [NSString stringWithFormat:@"featurepoint_%lld",frame.rawFeaturePoints.identifiers[i]];
445-
446-
[featurePoints addObject:@{
447-
@"x": @(point[0]),
448-
@"y": @(point[1]),
449-
@"z": @(point[2]),
450-
@"id":pointId,
451-
}];
452-
453-
}
454454

455-
self.onFeaturesDetected(@{
456-
@"featurePoints":featurePoints
457-
});
455+
if(self.onFeaturesDetected) {
456+
self.onFeaturesDetected(@{
457+
@"featurePoints":featurePoints
458+
});
459+
}
458460
});
459461
}
460462
}

0 commit comments

Comments
 (0)