Reputation: 20148
I am creating a box to place in my AR Scene with this code below:
let box = SCNBox(width: side, height: side, length: side, chamferRadius: 0.008)
box.firstMaterial?.diffuse.contents = UIColor(red: 220/255, green: 65/255, blue: 23/255, alpha: 0.6)
box.firstMaterial?.diffuse.contents = UIImage(named:"test1")!
let nodo = SCNNode(geometry: box)
nodo.position = position
What I am trying to figure out is how to make the box have a constant size in screen size (image space).
I would like to have the box node placed in the 3D scene to always look the same size, lets say 30x30 pixels...
So no matter how far or close I am to the box as I move around the ARKit camera moving the phone, I want the box to always show up the same size on screen when in viewport.
How can I achieve that?
Upvotes: 0
Views: 226
Reputation: 19882
If you need your object to be in 3D, the solution is to scale it every frame using the distance between the object and the camera. There's a similar answer here.
If you want a 2d plane, you could place it using UIKit
and updating its position every frame by projecting the 3D point to a 2D system and using those values as the coordinates for the view. (Reference)
Upvotes: 1