@@ -135,7 +135,7 @@ - (NSDictionary *)getSceneObjectsHitResult:(const CGPoint)tapPoint {
135135 SCNHitTestRootNodeKey: self.localOrigin ,
136136 SCNHitTestSortResultsKey: @(YES )
137137 };
138- NSArray <SCNHitTestResult *> *results = [_arView hitTest: tapPoint options: options];
138+ NSArray <SCNHitTestResult *> *results = [_arView hitTest: tapPoint options: options];
139139 NSMutableArray * resultsMapped = [self mapHitResultsWithSceneResults: results];
140140 NSDictionary *result = getSceneObjectHitResult (resultsMapped, tapPoint);
141141 return result;
@@ -156,39 +156,32 @@ - (NSDictionary *)getSceneObjectsHitResult:(const CGPoint)tapPoint {
156156- (NSMutableArray *) mapHitResultsWithSceneResults : (NSArray <SCNHitTestResult *> *)results {
157157
158158 NSMutableArray *resultsMapped = [NSMutableArray arrayWithCapacity: [results count ]];
159+
159160 [results enumerateObjectsUsingBlock: ^(id obj, NSUInteger index, BOOL *stop) {
160161 SCNHitTestResult *result = (SCNHitTestResult *) obj;
161162 SCNNode * node = result.node ;
162- NSArray *keys = [self .nodes allKeysForObject: node];
163- if ([keys count ]) {
164-
165- NSString * firstKey = [keys firstObject ];
166-
167- SCNVector3 point = result.worldCoordinates ;
168- SCNVector3 normal = result.worldNormal ;
169-
170- float distance = [self getCameraDistanceToPoint: point];
171- [resultsMapped addObject: (@{
172- @" id" : firstKey,
173- @" distance" : @(distance),
174- @" point" : @{
175- @" x" : @(point.x ),
176- @" y" : @(point.y ),
177- @" z" : @(point.z )
178- },
179- @" normal" : @{
180- @" x" : @(normal.x ),
181- @" y" : @(normal.y ),
182- @" z" : @(normal.z )
183-
184- }
185- } )];
186- } else {
187- NSLog (@" no key found for node %@ " , node);
188- NSLog (@" for results %@ " , results);
189- NSLog (@" all nodes %@ " , self.nodes );
190- NSLog (@" origin %@ " , self.localOrigin );
191- }
163+
164+
165+ SCNVector3 point = result.worldCoordinates ;
166+ SCNVector3 normal = result.worldNormal ;
167+ NSString * nodeId = node.name ;
168+ float distance = [self getCameraDistanceToPoint: point];
169+ [resultsMapped addObject: (@{
170+ @" id" : nodeId,
171+ @" distance" : @(distance),
172+ @" point" : @{
173+ @" x" : @(point.x ),
174+ @" y" : @(point.y ),
175+ @" z" : @(point.z )
176+ },
177+ @" normal" : @{
178+ @" x" : @(normal.x ),
179+ @" y" : @(normal.y ),
180+ @" z" : @(normal.z )
181+
182+ }
183+ } )];
184+
192185
193186 }];
194187 return resultsMapped;
0 commit comments