That seems a weird behavior but I'm wondering if there is a way to have nodes that have the same size on screen no matter how far it is from the camera?
I'm trying to show 2D elements in a city (just a text and an image) and some of them can be far but I still want the text and images to be visible but I also don't want it to look gigantic when I'm too close from it.
I'm currently using Apple SpriteKit example:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)
{
guard let sceneView = self.view as? ARSKView else
{
return
}
// Create anchor using the camera's current position
if let currentFrame = sceneView.session.currentFrame
{
// Create a transform with a translation of 0.2 meters in front of the camera
var translation = matrix_identity_float4x4
translation.columns.3.z = -0.2
let transform = simd_mul(currentFrame.camera.transform, translation)
// Add a new anchor to the session
let anchor = ARAnchor(transform: transform)
sceneView.session.add(anchor: anchor)
}
}
The only thing that 'works' for me so far is re-update the scale value for each Node:
func view(_ view: ARSKView, didUpdate node: SKNode, for anchor: ARAnchor)
{
node.setScale(1)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With