//
//  SlideParticleEditor.swift
//  SceneKitSessionWWDC2014
//
//  Created by haharsw on 2019/10/14.
//  Copyright © 2019 haharsw. All rights reserved.
//

import SceneKit
import SpriteKit

class SlideParticleEditor: SlideBase {
    
    override func setupSlide(slideManager: SlideManager) {
        let _ = textManager.setTitle("3D Particle Editor")
        
        let _ = textManager.addBullet("Integrated into Xcode", at: 0)
        let _ = textManager.addBullet("Edit .scnp files", at: 0)
        let _ = textManager.addBullet("Particle templates available", at: 0)
    }
    
    override func didOrderIn(slideManager: SlideManager) {
        // Bring up a screenshot of the editor
        let editorScreenshotNode = SCNNode.planeNodeWithImageName("particleEditor", size: 14, isLit: true)
        editorScreenshotNode.geometry?.firstMaterial?.diffuse.mipFilter = .linear
        editorScreenshotNode.position = SCNVector3(17, 3.8, 5)
        editorScreenshotNode.rotation = SCNVector4(0, 1, 0, -Float.pi / 1.5)
        groundNode.addChildNode(editorScreenshotNode)
        
        // Animate it (rotate and move)
        SCNTransaction.begin()
        SCNTransaction.animationDuration = 1.0
        editorScreenshotNode.position = SCNVector3(7, 3.8, 5)
        editorScreenshotNode.rotation = SCNVector4(0, 1, 0, -Float.pi / 7.0)
        SCNTransaction.commit()
    }
}
