Magic Leap MagicScript Landscape Application. ParticleNode (Use PopcornFX)

Prepare
Magic Leap One
https://www.magicleap.com/magic-leap-one

mlsdk v.0.20.0
https://creator.magicleap.com/downloads/lumin-sdk/overview

magic-script-cli v2.0.1
https://www.npmjs.com/package/magic-script-cli

PopcornFX 1.12.x editor (Latest)
https://wiki.popcornfx.com/index.php/PK-Editor_v1.12

**Create Particle Package**

No.1 
TutorialParticles Download & Create New.
Project Name (Folder Name) : **Project01**.
![Capture_000099.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/19029/7451f6d5-ceca-b10a-3936-fd4c5c0981cc.jpeg)
No.2 
Import.
![Capture_000098.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/19029/891c1e80-eb31-de41-c89b-42245e3a96d7.jpeg)
No.3
Open Project01
![Capture_000100.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/19029/ac1aab12-85e0-6aee-3e44-51e919e97593.jpeg)
No.4
Menu: Edit -> Project Settings.
![Capture_000103.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/19029/bc5bab7b-d72a-7410-6d69-10573441cffc.jpeg)
No.5
Assets->Baking
Enter the Baking Root folder name.
Click New button.
![Capture_000101.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/19029/99fd17f5-8ca3-9918-01c8-b963999908e3.jpeg)
OK![Capture_000102.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/19029/2642a97a-cdee-c1c7-0d86-7f27c796577b.jpeg)
No.6
After selecting Smoke 02, Bake.
![Capture_000104.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/19029/30b8be8d-a93c-81b6-2763-e879d073a652.jpeg)
Bake Settings
![Capture_000106.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/19029/f45b63d8-b438-5ea0-e8e2-70b639732bb6.jpeg)
No.7
Bake complete. Load the project created in the BAKE folder from the application and use it.
![Capture_000105.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/19029/ca312155-a73a-df7c-ae10-f7571e164323.jpeg)

**Create Project**

```sh
magic-script init my-particle org.magicscript.particle "Particle"
cd my-particle
mkdir res
```
Place the **Project 01** created in the BAKE folder in the res folder.

**Code**

Change app.package

```sh
DATAS = "digest.sha512.signed" : "." \
        "bin/" : "bin/" \
        "res/" : "res/"
OPTIONS = package/minApiLevel/2
```
Change app.js

```jsx
import { 
    LandscapeApp
  , ui} from 'lumin';
const { UiButton } = ui;

export class App extends LandscapeApp {
  onAppStart () {
    let isPlay = false;
    const prism = this.requestNewPrism([1.0, 3.0, 1.0]);
    const res = prism.createParticlePackageResourceId(
      "res/Project01");
    
    const p = prism.createParticleNode(res);
    p.setEffectName("Particles/Smoke02.pkfx");
    p.setLocalPosition([0, -0.5, -0.4]);
    
    const button = UiButton.Create(prism, 'Play', 0, 0.1);
    button.onActivateSub(function (uiEventData) {
        if (isPlay)
        {
            p.stop();
            button.setText("Play");
        }
        else
        {
            p.play();
            button.setText("Stop");
        }
        isPlay = !isPlay;
    });
    prism.getRootNode().addChild(button);
    prism.getRootNode().addChild(p);
  }
}
```

**Build**

```sh
magic-script build -i
```

**Run**

```sh
magic-script run --port=10000
```

**Reference**
ParticleNode(Magic Script API Doc)
https://docs.magicscript.org/lumin.ParticleNode.html

magicscript
https://www.magicscript.org/

Thanks!