I have a simple tube node in my scene that isn't displaying properly.

When I rotate it to face the camera, more than half of it is covered by some invisible sheet. When I rotate the tube enough, it gets completely covered by the sheet. Here is a screenshot showing my problem:

enter image description here

As you can see, the red tube is covered on its top-end. If I were to rotate it far enough, it would disappear.

There is nothing complex in my code, it's all very simple. In fact, here is is:

// Create tube geometry.
    let tubeGeometry = SCNTube(innerRadius: 5.0, outerRadius: 6.0, height: 200.0)
    tubeGeometry.firstMaterial!.diffuse.contents = UIColor.redColor()/*UIImage(named: "GreenTube")*/

    // Create tube node.
    let tube = SCNNode(geometry: tubeGeometry)
    tube.position = SCNVector3Make(0.0, -11.0, 0.0)
    tube.rotation = SCNVector4Make(1.0, 0.0, 0.0, Float(M_PI_2))
  • \$\begingroup\$ It looks like it might be getting clipped against the camera's near or far plane, but it's hard to say without seeing it in motion. \$\endgroup\$ – DMGregory Feb 5 '16 at 2:30
  • \$\begingroup\$ @DMGregory Near or far plane. Do you mean xFov and yFov? I will try resetting those and let you know how it goes. \$\endgroup\$ – Christian Kreiter Feb 5 '16 at 2:58
  • \$\begingroup\$ No, the near & far clipping planes are the closest and furthest depth values, respectively, that the camera will render. Anything closer than the near plane or further than the far gets clipped off sharply — the visible elliptical cross-section of your tube looks like this telltale effect. \$\endgroup\$ – DMGregory Feb 5 '16 at 3:02
  • \$\begingroup\$ Oh. I have never heard of that before. Messing with the FOV fixed it for me, but I'll watch out for the near & far next time. Thanks! \$\endgroup\$ – Christian Kreiter Feb 5 '16 at 3:50
  • \$\begingroup\$ Cool! Be sure to write up what worked for you as an answer and (after any required wait) mark it accepted. That will help others with this problem in future find your tested fix. \$\endgroup\$ – DMGregory Feb 5 '16 at 3:59

I fixed it! It turns out my Field of Vision was set too low. I went into my custom camera's xFov and yFov and set them to be a bit bigger than the length of my tube. My tube was merely going out of view too soon :)

  • \$\begingroup\$ Yes, thank you. I have to wait 2 days first :) \$\endgroup\$ – Christian Kreiter Feb 5 '16 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.