I would like to draw a line (or a very thin SCNCylinder) that traces the ray which was used to determine an SCNHitResult which I got from an SCNView using its hitTest:options method.
NSArray *hitResults = [self.skView hitTest:point options:nil];
My problem is that I need two points to construct this line: The origin (which is the SCNScene's pointOfView.position) and the point where the ray hit the first object (of which I don't know how to get the position).
Is there a way to get the position of the first hit SCNGeometry from the hit test? I have been trying the unprojectPoint: method of the SCNView to no avail. Thanks for any pointers.
Check this code
NSArray *hitResults = [self.skView hitTest:point options:nil];
// check that we clicked on at least one object
if ([hitResults count] > 0) {
// retrieved the first clicked object
SCNHitTestResult * result = [hitResults firstObject];
result.localCoordinates //position relative to local in V3
result.worldCoordinates //position relative to world in V3
}
I hope this helps you
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.