2

I create a macOS single window application and add a Sprite Particle System file with template Stars. and the visual effect just like this: enter image description here

And I want to add it to my viewController, as the guide of this answer, I got the result like this, and it was not which I desired:

    override func viewDidLoad() {
        super.viewDidLoad()

        let scene = SCNScene()
        let particlesNode = SCNNode()
        let particleSystem = SCNParticleSystem(named: "Welcome", inDirectory: "")
        particlesNode.addParticleSystem(particleSystem!)
        scene.rootNode.addChildNode(particlesNode)
        skView.backgroundColor = .black
        skView.scene = scene
    }

enter image description here

So, I'm wondering what's wrong and what should I do?

Here is the demo repo: Link Here

The particle system itself is the standard "star" SceneKit particle system available in Xcode, with no changes.

Community
  • 1
  • 1
HamGuy
  • 916
  • 1
  • 7
  • 18
  • Can you post your class/object information? Did you inherit `SK/SCNView`? Override `viewDidLoad`? – Fluidity Nov 26 '16 at 02:59
  • @Fluidity Sorry for the late reply. I just create a new demo and upload it to my gitlab repo:[link here](https://gitlab.com/hamguy/StarAnimationDemo). – HamGuy Nov 26 '16 at 15:21

1 Answers1

1

Well I made a little progress. If I swivel the camera around 180 degrees, I can see the stars receding, so we can tell that the particle system is running ok. In the default orientation, though, all I saw was blinking lights. So I think the particles are being generated with a Z position of 0, the same as the camera's.

If I move the system's node away from the camera

    particlesNode.position = SCNVector3(0, 0, -20)

I still just see blinking lights. But if I click on the SCNView, the animation works correctly. I see stars coming at me.

I don't understand why I have to click the view to get it to work right. I tried isPlaying = true but that made no difference.

Hal Mueller
  • 7,019
  • 2
  • 24
  • 42
  • I moved the node away from the camera after the particle system add to the node, but just see blinking lights once the application start, clicked the view but see nothing. I'm just confused maybe I had misunderstood your answer.[new commit here](https://gitlab.com/hamguy/StarAnimationDemo/commit/3572d25d4767fa74603aba40e915b8608dcd8008) – HamGuy Nov 28 '16 at 08:46
  • 1
    File a Radar on this, please. The behavior is not correct, and appears to be different on our respective machines (I'm testing with Xcode 8.1, OS X 10.11.6). – Hal Mueller Nov 28 '16 at 22:20
  • File a Radar? I'm so sorry but I can not get it. I'm testing with Xcode 8.1 & macOS sierra 10.12. Would you mind to share your demo? – HamGuy Nov 29 '16 at 02:45
  • @HamGuy a 'radar' is the filing of a bug report to Apple. Apple has one of the most tedious, annoying and infuriating bug reporting systems known to man. You will want to reach through the screen and wring the neck of the people responsible for the 'design' of this: https://bugreport.apple.com/ – Confused Nov 29 '16 at 11:05