SceneKit, 'hit' testing between camera orientation and geometry

我们两清 提交于 2019-12-05 21:45:18

I haven't tried this but...

SCNHitTestResult returns, among other things, textureCoordinatesWithMappingChannel(_:). Documentation cites the example of adding scorch marks to a game character's texture after it's been hit by a laser.

It appears that SCNNode's

hitTestWithSegmentFromPoint(_ pointA: SCNVector3,
                     toPoint pointB: SCNVector3,
                     options options: [String : AnyObject]?) -> [SCNHitTestResult]

will give you the hits you need, between the camera and the geometry, regardless of the orientation of the camera. If the camera and the target are using different local node coordinate systems, you'll have to do some conversion using convertPosition(_:from:Node:) or similar functions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!