3 Replies
      Latest reply on May 20, 2020 12:29 PM by parker9
      KOPPEL Level 1 Level 1 (0 points)

        how do I determine which side is up? (Scenekit, Swift)

         

        I make a cube (Dice) that spins around how do I determine which side are facing up

         

        var Materials : [SCNMaterial] = [SCNMaterial(),SCNMaterial(),SCNMaterial(),SCNMaterial(),SCNMaterial(),SCNMaterial()]; // Dice

        ...

                Materials[0].diffuse.contents = UIImage(named: "Dice5.png");

                Materials[1].diffuse.contents = UIImage(named: "Dice2.png");

                Materials[2].diffuse.contents = UIImage(named: "Dice3.png");

                Materials[3].diffuse.contents = UIImage(named: "Dice4.png");

                Materials[4].diffuse.contents = UIImage(named: "Dice1.png");

                Materials[5].diffuse.contents = UIImage(named: "Dice6.png");

        ...

                BoxNode.physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.Dynamic, shape: nil)

                BoxNode.physicsBody?.mass = 5

                BoxNode.name = "Delete"

              

             

                BoxNode.physicsBody!.applyForce(SCNVector3Make(0, 0, 14), impulse: true)

        ...

                let Wait = SCNAction.waitForDuration(2)

                let FadeOut = SCNAction.fadeOutWithDuration(1)

                let Sequence = SCNAction.sequence([Move, Wait, FadeOut])

            

                BoxNode.runAction(Sequence,completionHandler:

                {

               

                   // Here I would like to determine which side that are facing up (1,2,3,4,5 or 6) - how do I do that

         

                })

            

            

                BoxNode.geometry!.materials = Materials; // set the Dice