Benny33
Benny33

Reputation: 505

SCNNode with constant scale from any camera position in SceneKit

I want to implement a SCNNode (backed by geometry) that stays a constant scale from any camera position (even when zooming in or out). Examples of these types of objects are in the SceneKit Editor such as the camera or 3D manipulator. Zooming closer to these objects doesn't change the size they appear. Similar to how an MKAnnotation works on a MapView. I would imagine that you have to modify the scale each time the camera position changes but I'm not sure how to pull this off.

Upvotes: 3

Views: 1069

Answers (1)

Hal Mueller
Hal Mueller

Reputation: 7646

Would it work for you to use an orthographic projection on your camera? That will make each node constant size, regardless of varying distance from camera.

Something like

view.pointOfView.usesOrthographicProjection = true

(pointOfView being an SCNCamera)

If you want only some nodes to be fixed size, then yes, you will need to rescale the node as the camera moves. You might be able to do this with a shader fragment, or maybe a Core Image filter.

Upvotes: 2

Related Questions