2 Replies
      Latest reply on Jul 23, 2018 6:41 PM by james_hillhouse
      koushan Level 1 Level 1 (0 points)

        Assigning a categoryBitMask to a SCNlight in iOS 12 (beta 3  & 4) has no effect. It works on the simulator but when running on an actual device its broken.

        The following code is a simple example showing whats wrong.

        Since the categoryBitMask for the light is different from the ball, the light should not light up the ball and the scene should be dark. But when we run this code on an actual device the ball is lit.


        struct Mask {
            static let mask1:Int = 0b1
            static let mask2:Int = 0b10
            static let mask3:Int = 0b100
            static let mask4:Int = 0b1000
        class GameViewController: UIViewController {
            override func viewDidLoad() {
                let scene = SCNScene()
                // Add Camera
                let cameraNode = SCNNode()
                cameraNode.camera = SCNCamera()
                cameraNode.position = SCNVector3(x: 0, y: 0, z: 2)
                // Add ball
                let ball = SCNSphere(radius: 0.1)
                ball.firstMaterial?.diffuse.contents = UIColor.white
                let ballNode = SCNNode(geometry: ball)
                // Add light
                let lightNode1 = SCNNode()
                lightNode1.light = SCNLight()
                lightNode1.light!.type = .directional
                lightNode1.light!.color = UIColor.yellow
                lightNode1.light?.castsShadow = true
                lightNode1.position = SCNVector3(x: 0, y: 10, z: 10)
                lightNode1.light?.categoryBitMask = Mask.mask2
                let scnView = self.view as! SCNView
                scnView.scene = scene


        Is there any other way I can use to exclude a light shining on a node until apple fixes this issue?