Instance Method

hitTest:options:

Searches the renderer’s scene for objects corresponding to a point in the rendered image.

Required.

Declaration

- (NSArray<SCNHitTestResult *> *)hitTest:(CGPoint)point options:(NSDictionary<SCNHitTestOption, id> *)options;

Parameters

thePoint

A point in the screen-space (view, layer, or GPU viewport) coordinate system of the scene renderer.

options

A dictionary of options affecting the search. See Hit Testing Options Keys for acceptable values.

Return Value

An array of SCNHitTestResult objects representing search results.

Discussion

A 2D point in the rendered screen coordinate space can refer to any point along a line segment in the 3D scene coordinate space. Hit-testing is the process of finding elements of a scene located along this line segment. For example, you can use this method to find the geometry corresponding to a click event in a SceneKit view.

See Also

Working With Projected Scene Contents

SCNHitTestOption

Options affecting the behavior of SceneKit hit-testing methods.

- isNodeInsideFrustum:withPointOfView:

Returns a Boolean value indicating whether a node might be visible from a specified point of view.

Required.

- nodesInsideFrustumWithPointOfView:

Returns all nodes that might be visible from a specified point of view.

Required.

- projectPoint:

Projects a point from the 3D world coordinate system of the scene to the 2D pixel coordinate system of the renderer.

Required.

- unprojectPoint:

Unprojects a point from the 2D pixel coordinate system of the renderer to the 3D world coordinate system of the scene.

Required.