3

I'm currently working on ARKit (SceneKit) app. I've noticed that if I put a node at 100m, the node will show just fine but if I set it to 101m or farther, it won't show.

Is this the distance limit?

var translation = matrix_identity_float4x4
translation.columns.3.x = 1
translation.columns.3.y = 1
translation.columns.3.z = -100
let transform = simd_mul(currentFrame.camera.transform, translation)
let anchor = ARAnchor(name: "test", transform: transform)
sceneView.session.add(anchor: anchor)

Is there any way to increase this range?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
pierre23
  • 3,846
  • 1
  • 28
  • 28

2 Answers2

3

For increasing a Camera's range use Far attribute in Z Clipping area of Attributes Inspector.

The default value is 100 meters.

enter image description here

var zFar: Double { get set }

Excerpt from Developer Documentation: The far value determines the maximal distance between the camera and a visible surface. If a surface is farther from the camera than this distance, the surface is clipped and does not appear. The default far value is 100.0.

let camera = SCNCamera()
camera.zFar = 1000

This post provides an important info.

enter image description here

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • Thank you so much for your very well detailed answer. That explains the 100m limit. My issue is that I'm using SpriteKit and not SceneKit. There is no SCNCamera. The only thing close to it I found is SKCameraNode but it doesn't have the zFar property. – pierre23 Oct 14 '18 at 04:31
  • Maybe you're having `SCNScene()` and/or `SK3DNode()`? Are you simultaneously using SpriteKit and SceneKit modules, or just SpriteKit itself (without SceneKit at all)? What's scene's type in your project: `Scene.sks` or `Scene.scn`? – Andy Jazz Oct 14 '18 at 12:21
  • I wanted to show just few very simple 2D elements so I created a SpriteKit project via Xcode. It created automatically Scene.sks file. It's kind of surprising I don't find a way to do it on SpriteKit. – pierre23 Oct 14 '18 at 14:49
  • That's ok. SpriteKit is a 2D framework. But! Do you have any `SCN` components in your `SKS` scene? Any. – Andy Jazz Oct 14 '18 at 15:06
  • No since I used ARSKView, it uses SKNode and Scene.sks scene file. ARSKView doesn't even allow me to use a Scene.scn file. – pierre23 Oct 14 '18 at 15:11
  • Try to use it via SK3DNode(). Or just use `SK` inside `SCNView`. – Andy Jazz Oct 14 '18 at 15:13
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/181841/discussion-between-gigantic-and-pierre23). – Andy Jazz Oct 14 '18 at 15:13
1

Looks like there is no way to update the Z maximum range for SpriteKit. Only SceneKit allows you to modify this by updating the zfar property from the camera. Thanks to Gigantic for your help!

pierre23
  • 3,846
  • 1
  • 28
  • 28